Here you can find the source of timeStampToString(Timestamp stamp, String dateTimeFormat, TimeZone tz, Locale locale)
public static String timeStampToString(Timestamp stamp, String dateTimeFormat, TimeZone tz, Locale locale)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; public class Main { /**/*from w w w. j a v a2 s. com*/ * Localized Timestamp to String conversion. To be used in tandem with * stringToTimeStamp(). */ public static String timeStampToString(Timestamp stamp, TimeZone tz, Locale locale) { return timeStampToString(stamp, null, tz, locale); } /** * Localized Timestamp to String conversion. To be used in tandem with * stringToTimeStamp(). */ public static String timeStampToString(Timestamp stamp, String dateTimeFormat, TimeZone tz, Locale locale) { DateFormat dateFormat = toDateTimeFormat(dateTimeFormat, tz, locale); dateFormat.setTimeZone(tz); return dateFormat.format(stamp); } /** * Returns an initialized DateFormat object. * * @param dateTimeFormat * optional format string * @param tz * @param locale * can be null if dateTimeFormat is not null * @return DateFormat object */ public static DateFormat toDateTimeFormat(String dateTimeFormat, TimeZone tz, Locale locale) { DateFormat df = null; if (dateTimeFormat == null) { df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(dateTimeFormat); } df.setTimeZone(tz); return df; } }