Here you can find the source of dateToString(java.util.Date date, String dateFmt)
public static String dateToString(java.util.Date date, String dateFmt)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; public class Main { public static String dateToString(java.util.Date date, String dateFmt) { String strTemp = null;// w ww . j a va 2 s .c om if (date != null) { String dtFmt = dateFmt; if (null == dtFmt) dtFmt = "yyyy-MM-dd"; SimpleDateFormat formatter = new SimpleDateFormat(dtFmt); strTemp = formatter.format(date); } return strTemp; } public static String dateToString(java.sql.Date date) { return dateToString(date, null); } public static String format(java.util.Date date) { return date == null ? "" : format(date, "yyyy-MM-dd"); } public static String format(java.util.Date date, String pattern) { return date == null ? "" : new SimpleDateFormat(pattern).format(date); } }