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.text.SimpleDateFormat; import java.util.Date; public class Main { public static String format(Date date, String pattern) { if (date == null) return ""; SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); }/*w ww . j a v a 2s. co m*/ public static String format(Date date) { return format(date, "yyyy-MM-dd"); } }