Android examples for java.util:Date Time
get Current Time String
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; public class Main { private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() { @Override//from w w w . j a v a2 s . co m protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); } }; public static String getCurTimeStr() { Calendar cal = Calendar.getInstance(); String curDate = dateFormater.get().format(cal.getTime()); return curDate; } }