Here you can find the source of getDate()
public static String getDate()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getDate() { SimpleDateFormat fromat = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.get(Calendar.YEAR);/*w w w . ja va2 s . c om*/ c.get(Calendar.MONTH + 1); c.get(Calendar.DAY_OF_MONTH); 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; } }