Java Millisecond Format getTime(long timeInMillis, SimpleDateFormat dateFormat)

Here you can find the source of getTime(long timeInMillis, SimpleDateFormat dateFormat)

Description

long time to string

License

Apache License

Parameter

Parameter Description
timeInMillis a parameter
dateFormat a parameter

Declaration

public static String getTime(long timeInMillis, SimpleDateFormat dateFormat) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static final SimpleDateFormat DATE_FORMAT_DATE_S = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**/*from ww  w.ja v  a2s.c  o m*/
     * long time to string
     * 
     * @param timeInMillis
     * @param dateFormat
     * @return
     */
    public static String getTime(long timeInMillis, SimpleDateFormat dateFormat) {
        return dateFormat.format(new Date(timeInMillis));
    }

    /**
     * long time to string, format is {@link #DEFAULT_DATE_FORMAT}
     * 
     * @param timeInMillis
     * @return
     */
    public static String getTime(long timeInMillis) {
        return getTime(timeInMillis, DATE_FORMAT_DATE_S);
    }
}

Related

  1. getFormattedAPILastAccessDate(long lastAccessTimeMillis)
  2. getMillisAsFormattedSeconds(long millis)
  3. getMvoDateFormatForMilliSecond()
  4. getReadableMillis(long startMillis, long endMillis)
  5. getReadableMillisTime(long millis)
  6. getTimeInMillis(String dateString, String format)
  7. microseconds2milliseconds(double us)
  8. millis2hms(final long t)
  9. millis2samples(long ms, double sampleRate)