Here you can find the source of timestamp2String(Timestamp timestamp, String pattern)
public static String timestamp2String(Timestamp timestamp, String pattern)
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss"; public static String timestamp2String(Timestamp timestamp, String pattern) { if (timestamp == null) { throw new java.lang.IllegalArgumentException("timestamp null illegal"); }//from ww w .ja va 2 s. co m if (pattern == null || pattern.equals("")) { pattern = PATTERN_STANDARD; } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(new Date(timestamp.getTime())); } }