Here you can find the source of formatDate(Date d)
public static String formatDate(Date d)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// www .j a v a 2 s .co m * yyyy-MM-dd */ public static final String DATE_PATTERN_DEFAULT = "yyyy-MM-dd"; public static String formatDate(Date d) { return format(d, DATE_PATTERN_DEFAULT); } public static String format(Date d, String pattern) { if (d == null) return null; SimpleDateFormat dateFromat = new SimpleDateFormat(pattern); return dateFromat.format(d); } }