Here you can find the source of timestamp2String(long source, DateFormat format)
public static String timestamp2String(long source, DateFormat format)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String timestamp2String(long source, DateFormat format) { return date2String(timestamp2Date(source), format); }//from w w w.j a va 2 s . c o m public static String timestamp2String(long source, String formatString) { return date2String(timestamp2Date(source), new SimpleDateFormat(formatString)); } public static String date2String(Date source, String formatString) { return date2String(source, new SimpleDateFormat(formatString)); } public static String date2String(Date source, DateFormat format) { try { return format.format(source); } catch (Exception e) { return ""; } } public static Date timestamp2Date(long source) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(source); return calendar.getTime(); } }