Here you can find the source of format(Date date)
public static String format(Date date)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String PATTERN_CLASSICAL = "yyyy-MM-dd HH:mm:ss"; public static String format(Date date) { return format(date, PATTERN_CLASSICAL); }//w w w. java 2s . c o m public static String format(Timestamp date) { return format(date, PATTERN_CLASSICAL); } public static String format(Date date, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } }