Java Time Elapsed elapsedTime(long milli)

Here you can find the source of elapsedTime(long milli)

Description

Formats a time interval in milliseconds to a String in the form "hours:minutes:seconds:millis"

License

Apache License

Declaration

public static String elapsedTime(long milli) 

Method Source Code

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

public class Main {
    /**/*  w ww  . j  a  v  a2s. c  om*/
     * Formats a time interval in milliseconds to a String in the form "hours:minutes:seconds:millis"
     */
    public static String elapsedTime(long milli) {
        long seconds = milli / 1000;
        milli %= 1000;

        long minutes = seconds / 60;
        seconds %= 60;

        long hours = minutes / 60;
        minutes %= 60;

        return hours + "h " + minutes + "m " + seconds + "s " + milli;
    }
}

Related

  1. elapsed(long from, long to)
  2. elapsedMicros(String startTime, String endTime)
  3. elapsedNanos(long nanoseconds)
  4. elapsedNanos(long startNanoTime)
  5. elapsedTime(long endTime, long beginTime)
  6. elapsedTime(long ms)
  7. elapsedTime(long startTime, long endTime, double units)
  8. elapsedTime(long timeInMs)
  9. elapsedTimeMs(long start)