Here you can find the source of formatDateTime(Timestamp t, String pattern)
public static String formatDateTime(Timestamp t, String pattern)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String STANDARD_DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public final static String STANDARD_DATE_PATTERN = "yyyy-MM-dd"; public static String formatDateTime(Timestamp t, String pattern) { return formatDate(new Date(t.getTime()), STANDARD_DATETIME_PATTERN); }/*from ww w.j a va 2 s .com*/ public static String formatDateTime(Date date) { return formatDate(date, STANDARD_DATETIME_PATTERN); } public static String formatDate(Timestamp t) { return formatDate(new Date(t.getTime())); } public static String formatDate(Timestamp t, String pattern) { return formatDate(new Date(t.getTime()), STANDARD_DATE_PATTERN); } public static String formatDate(Date date) { return formatDate(date, STANDARD_DATE_PATTERN); } public static String formatDate(Date date, String pattern) { if (date == null) return null; DateFormat format = new SimpleDateFormat(pattern); return format.format(date); } }