Here you can find the source of formatDate(String format, long timestamp)
public static String formatDate(String format, long timestamp)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(String format, long timestamp) { Date date = timestampToDate(timestamp); SimpleDateFormat f = new SimpleDateFormat(format); return f.format(date); }//from w w w . j a va 2s . c om /** * Convert a unix timestamp to a Date object. The date object works with milliseconds while unix timestamps are * in seconds. * @param stamp long * @return Date */ public static Date timestampToDate(long stamp) { return new Date(stamp * 1000); } }