Java Time Print printTime(long time, String spacer)

Here you can find the source of printTime(long time, String spacer)

Description

print Time

License

Open Source License

Declaration

public static String printTime(long time, String spacer) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

public class Main {
    public static final String directionDummy = "     ";

    public static String printTime(long time) {
        return printTime(time, "");
    }//from w  w  w  .  j  a  v a  2 s  . c om

    public static String printTime(long time, String spacer) {
        long minutes, seconds, milliseconds;
        minutes = (time / 1000) / 60;
        seconds = (time - minutes * 1000 * 60) / 1000;
        milliseconds = (time - seconds * 1000 - minutes * 1000 * 60);

        String result = directionDummy + spacer + "Time: ";
        result += String.format("%02d", minutes) + ":";
        result += String.format("%02d", seconds) + ".";
        result += String.format("%03d", milliseconds);
        return result;
    }
}

Related

  1. printTime(long millis)
  2. printTime(long starttime, long endtime)
  3. printTime(String msg)
  4. printTimer(String blah)
  5. printTimes(String what, long... args)
  6. printTimestamp()