Java Millisecond Format formatTime(long millis)

Here you can find the source of formatTime(long millis)

Description

Returns a string representation of the specified time value in hh:mm:ss.SSS format in the local time zone.

License

MIT License

Parameter

Parameter Description
millis a timestamp in milliseconds.

Return

the string representation of the specified time.

Declaration

public static String formatTime(long millis) 

Method Source Code

//package com.java2s;
/*//  ww w  . j a  va2  s . c  om
 * Copyright (c) 2015-2016 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String TIME_FORMAT_HH_MM_SS_SSS = "HH:mm:ss.SSS";

    /**
     * Returns a string representation of the specified time value
     * in hh:mm:ss.SSS format in the local time zone.
     *
     * @param millis a timestamp in milliseconds.
     * @return the string representation of the specified time.
     */
    public static String formatTime(long millis) {
        SimpleDateFormat f = new SimpleDateFormat(TIME_FORMAT_HH_MM_SS_SSS);
        return f.format(new Date(millis));
    }
}

Related

  1. formatSystemTime(long millis)
  2. formattedMillis(long millis)
  3. formatTime(long currentTimeMillis)
  4. formatTime(long localCreationTimeMillis)
  5. formatTime(long millis)
  6. formatTimeInMillis(long millis)
  7. formatTimeMillis(long millis)
  8. formatTimeMillis(long timeMillis)
  9. formatTimestamp(long millis)