Here you can find the source of dateFormat(Date date, String pattern)
public static String dateFormat(Date date, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DATE_PATTERN = "yyyy-MM-dd"; public static String dateFormat(Date date, String pattern) { if (pattern == null || "".equals(pattern.trim())) { pattern = DATE_PATTERN;/*from w w w .j a va 2 s . c o m*/ } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } }