Here you can find the source of formatTimestamp(Long mills)
public static final String formatTimestamp(Long mills)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w ww .j a v a 2s.c om*/ * @param aDate * @return formated time by yyyy-MM-dd HH:mm:ss */ public static final <T extends Date> String formatTimestamp(T date) { if (date == null) return null; SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return timestampFormat.format(date); } public static final String formatTimestamp(Long mills) { return formatTimestamp(new Date(mills)); } /** * @param date * @param pattern: Date format pattern * @return */ public static final <T extends Date> String format(T date, String pattern) { if (date == null) return null; try { SimpleDateFormat df = new SimpleDateFormat(pattern); String result = df.format(date); return result; } catch (Exception e) { return null; } } }