Here you can find the source of formatDate(long ms)
public static String formatDate(long ms)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String defaultFormat = "yyyy-MM-dd HH:mm:ss"; public static String formatDate(Date date) { return formatDate(date, defaultFormat); }//from w w w .j ava2 s . co m public static String formatDate(long ms) { return formatDate(new Date(ms), defaultFormat); } public static String formatDate(Date date, String format) { if (date == null) { return null; } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }