Here you can find the source of formatDate(Date date, String format)
public static String formatDate(Date date, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; public static String formatDate(Date date) { if (date == null) { return ""; }/*from www . j a va 2s.c om*/ return new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(date); } public static String formatDate(Date date, String format) { if (date == null) { return null; } return new SimpleDateFormat(format).format(date); } }