Here you can find the source of format(Date date)
public static String format(Date date)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final ThreadLocal<DateFormat> COMMON_FORMAT = new ThreadLocal<DateFormat>() { @Override/*from w w w .j a v a 2s . co m*/ protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; public static String format(Date date) { return COMMON_FORMAT.get().format(date); } }