Here you can find the source of timeStampToString(Timestamp date, String dateFmt)
public static String timeStampToString(Timestamp date, String dateFmt)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; public class Main { public static String timeStampToString(Timestamp date, String dateFmt) { String strTemp = null;//from w w w . j a va 2 s. co m 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 timeStampToString(Timestamp date) { return timeStampToString(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); } }