Java Time Format formatTimeNicely(long millis)

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

Description

format Time Nicely

License

BSD License

Declaration

public static String formatTimeNicely(long millis) 

Method Source Code

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

public class Main {
    public static String formatTimeNicely(long millis) {
        int seconds = (int) Math.round(millis / 1000.0);
        int minutes = seconds / 60;
        int hours = minutes / 60;
        seconds = seconds % 60;//  w  ww .  ja va 2s  . c om
        minutes = minutes % 60;
        if (hours > 0) {
            return hours + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds);
        } else {
            return minutes + ":" + String.format("%02d", seconds);
        }
    }
}

Related

  1. formatTimeInNanos(long time)
  2. formatTimeInterval(final long time)
  3. formatTimeInterval(long in)
  4. formatTimeLength(long ms)
  5. formatTimeLikeTimer(long time, boolean appendMs)
  6. formatTimeOffset(long offset)
  7. formatTimePart2(long number, String unit)
  8. formatTimePeriod(long millis)
  9. formatTimePeriod(long timePeriod)