Here you can find the source of getFormattedTime(long timestamp, String format)
public static String getFormattedTime(long timestamp, String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String TIMESTAMP_FORMAT = "y-MM-dd_HH-mm-ss"; public static String getFormattedTime(long timestamp, String format) { if (format == null) { format = TIMESTAMP_FORMAT;//from w ww . j av a2 s. c o m } SimpleDateFormat dateformat = new SimpleDateFormat(format); return dateformat.format(new Date(timestamp)); } }