Here you can find the source of timestampToString(Timestamp timestamp, String pattern)
public static String timestampToString(Timestamp timestamp, String pattern)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.SimpleDateFormat; public class Main { public static String timestampToString(Timestamp timestamp, String pattern) { SimpleDateFormat simpledateformat = new SimpleDateFormat(pattern); return simpledateformat.format(timestamp); }/*from w w w .j av a 2 s .c om*/ public static String format(java.util.Date date, String format) { String result = ""; try { if (date != null) { java.text.DateFormat df = new java.text.SimpleDateFormat(format); result = df.format(date); } } catch (Exception e) { } return result; } public static String format(java.util.Date date) { return format(date, "yyyy/MM/dd"); } }