Java Time Format formatTime(long millis)

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

Description

format Time

License

Open Source License

Declaration

public static String formatTime(long millis) 

Method Source Code

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

public class Main {
    public static String formatTime(long millis) {
        long seconds = millis / 1000;
        if (seconds < 0) {
            return millis + "ms";
        } else if (seconds < 60) {
            return seconds + "s";
        } else {/*from   w  w  w  .  j av a2s  .  c  om*/
            long minutes = seconds / 60;
            seconds = seconds % 60;
            return minutes + "m " + seconds + "s";
        }
    }
}

Related

  1. formatTime(long elapsedTime)
  2. formatTime(long elapsedTime)
  3. formatTime(long millis)
  4. formatTime(long millis)
  5. formatTime(long millis)
  6. formatTime(long millis, int precision)
  7. formatTime(long ms)
  8. formatTime(long ms)
  9. formatTime(long msElapsed)