Android examples for java.util:Date
get Current Date in String
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main{ public static String getCurDateStr() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); return c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + c.get(Calendar.DAY_OF_MONTH) + "-" + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); }//from ww w. j a v a 2 s .co m public static String getCurDateStr(String format) { Calendar c = Calendar.getInstance(); return date2Str(c, format); } }