Here you can find the source of getCurrDatetimeWithDbFormat()
public static String getCurrDatetimeWithDbFormat()
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static ThreadLocal<DateFormat> dbDateFormatThreadLocal = new ThreadLocal<DateFormat>() { @Override//w w w . ja va 2 s . c o m protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; public static String getCurrDatetimeWithDbFormat() { DateFormat dbDateFormat = dbDateFormatThreadLocal.get(); return dbDateFormat.format(new Date()); } }