Here you can find the source of getAccurateDate()
public static String getAccurateDate()
//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; } }