Here you can find the source of format(Date d, String format)
public static String format(Date d, String format)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String format(Date d, String format) { return format(d, format, Locale.getDefault()); }/*from w w w . j av a 2s.co m*/ public static String format(Date d, String format, Locale locale) { if (d == null) return ""; DateFormat df = new SimpleDateFormat(format, locale); return df.format(d); } }