Here you can find the source of getFormattedTime(String dateTimeFormat, long timestamp)
Parameter | Description |
---|---|
dateTimeFormat | the date-time format |
timestamp | the timestamp to be formatted |
public static String getFormattedTime(String dateTimeFormat, long timestamp)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**//from w w w . j a v a2 s. c o m * Method to get the current date-time in the input format. * * @param dateTimeFormat * the date-time format * @param timestamp * the timestamp to be formatted * @return the current date-time in the input format */ public static String getFormattedTime(String dateTimeFormat, long timestamp) { Date date = new Date(timestamp); SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, Locale.US); return sdf.format(date); } }