Here you can find the source of format(Date date)
public static String format(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String YYYY_MM_DD = "yyyy-MM-dd"; public static String format(Date date, String pattern) { if (date == null) return ""; else//from ww w .j a v a2 s .com return getFormatter(pattern).format(date); } public static String format(Date date) { if (date == null) return ""; else return getFormatter(YYYY_MM_DD).format(date); } private static SimpleDateFormat getFormatter(String parttern) { return new SimpleDateFormat(parttern); } }