Here you can find the source of formatDate(long timestamp, String format)
public static String formatDate(long timestamp, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String formatDate(Date date, String format) { if (format == null || "".equals(format)) { format = "yyyy-MM-dd HH:mm:ss"; }/* w w w . j ava2 s .c o m*/ SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } public static String formatDate(long timestamp, String format) { if (format == null || "".equals(format)) { format = "yyyy-MM-dd HH:mm:ss"; } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(new Date(timestamp)); } }