Here you can find the source of format(Date date, String pattern)
public static String format(Date date, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String DATE_FORMAT = "yyyy-MM-dd"; public static String format(Date date, String pattern) { if (date == null) { return null; }// w w w. j ava2 s . c o m SimpleDateFormat sf = new SimpleDateFormat(pattern); return sf.format(date); } public static String format(Date date) { return format(date, DATE_FORMAT); } }