Here you can find the source of format(Date time, String pattern)
public static String format(Date time, String pattern)
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String format(Timestamp time, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(new Date(time.getTime())); }/*from w ww .j a v a 2 s. c o m*/ public static String format(Date time, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(time); } }