Android Date to Timestamp Convert getAccurateDate()

Here you can find the source of getAccurateDate()

Description

get Accurate Date

Declaration

public static String getAccurateDate()

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String getAccurateDate() {
        SimpleDateFormat fromat = new SimpleDateFormat("yyyyMMddHHmm");
        Calendar c = Calendar.getInstance();
        c.get(Calendar.YEAR);/*from   ww  w  . ja v  a 2  s .  c  o  m*/
        c.get(Calendar.MONTH + 1);
        c.get(Calendar.DAY_OF_MONTH);
        c.get(Calendar.HOUR_OF_DAY);
        c.get(Calendar.MINUTE);
        String time = fromat.format(c.getInstance().getTime());
        return time;
    }

    private static String format(int x) {
        String s = "" + x;
        if (s.length() == 1)
            s = "0" + s;
        return s;
    }
}

Related

  1. Date2Timestamp(Date d)
  2. convertToTimeStamp(Date date)
  3. convertToTimeStamp(Date date, boolean showSeconds)
  4. unixTimestampFromDate(final Date date)
  5. getAccurateDate(Date date)
  6. toFullDate(Date date)