Here you can find the source of getCurTimeStr()
public static String getCurTimeStr()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private final static ThreadLocal<SimpleDateFormat> DATE_FORMATER = new ThreadLocal<SimpleDateFormat>() { @Override/*from w w w . j a v a2s . co m*/ protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; public static String getCurTimeStr() { Calendar cal = Calendar.getInstance(); String curDate = DATE_FORMATER.get().format(cal.getTime()); return curDate; } }