Java Time Format formatTime(long time)

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

Description

format Time

License

Open Source License

Parameter

Parameter Description
time in milliseconds that should be converted

Return

a String, e.g like this: 24 Tag(e), 15 Stunde(n), 13 Minute(n), 1 Sekunde(n)

Declaration

public static String formatTime(long time) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*www.  ja  v a  2s. c  o m*/
     *
     * @param time in milliseconds that should be converted
     * @return a String, e.g like this: 24 Tag(e), 15 Stunde(n), 13 Minute(n), 1
     * Sekunde(n)
     */
    public static String formatTime(long time) {
        long second = (time / 1000) % 60;
        long minute = (time / (1000 * 60)) % 60;
        long hour = (time / (1000 * 60 * 60)) % 24;
        long day = (time / (1000 * 60 * 60 * 24));
        return String.format("%d Tag(e), %02d Stunde(n), %02d Minute(n) und %02d Sekunde(n)", day, hour, minute,
                second);
    }
}

Related

  1. formatTime(long seconds)
  2. formatTime(long time)
  3. formatTime(long time)
  4. formatTime(long time)
  5. formatTime(long time)
  6. formatTime(long time)
  7. formatTime(long time)
  8. formatTime(long time)
  9. formatTime(long time)