Here you can find the source of formatDate(final Date date, final String defaultValue)
public static String formatDate(final Date date, final String defaultValue)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); /**/* w ww . ja v a2 s . co m*/ * Format the Date using pattern "yyyy-MM-dd" * * @param date * @return */ public static String formatDate(final Date date) { return formatDate(date, null); } public static String formatDate(final Date date, final String defaultValue) { if (date == null) { return defaultValue; } return dateFormat.format(date); } }