Here you can find the source of formatDataTimeStamp(final long timeInMillis)
Parameter | Description |
---|---|
timeInMillis | a time in Millis |
public static String formatDataTimeStamp(final long timeInMillis)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**/* w w w. j a v a2s . c o m*/ * Formats a date into a standard timestamp format: yy-MM-dd HH:mm:ss.SSS * * @param timeInMillis * a time in Millis * @return a String timestamp */ public static String formatDataTimeStamp(final long timeInMillis) { final String timeFormat = "yy-MM-dd HH:mm:ss.SSS"; return formatDateTimeStamp(timeInMillis, timeFormat); } /** * 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; } }