Here you can find the source of formatDateTimeStamp(final long timeInMillis, final String dateFormatString)
Parameter | Description |
---|---|
timeInMillis | a time in Millis |
dateFormatString | a time format String |
public static String formatDateTimeStamp(final long timeInMillis, final String dateFormatString)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**/*from w w w . java 2 s .c o m*/ * Formats a date into a given timestamp format. * * @param timeInMillis * a time in Millis * @param dateFormatString * a time format String * @return a String timestamp */ public static String formatDateTimeStamp(final long timeInMillis, final String dateFormatString) { String tmpString = ""; // Convert the timeInMillis to Date Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timeInMillis); java.util.Date date = cal.getTime(); // Format it SimpleDateFormat format = new SimpleDateFormat(dateFormatString); tmpString = format.format(date); return tmpString; } }