Java Time Format formatTime(double time)

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

Description

format Time

License

Open Source License

Declaration

public static String formatTime(double time) 

Method Source Code

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

public class Main {
    public static String formatTime(double time) {
        int hours = (int) time / 3600;
        int minutes = (int) (time - (hours * 3600)) / 60;
        int seconds = (int) time - (hours * 3600) - (minutes * 60);
        String hoursString = hours + "";
        String minutesString = minutes + "";
        String secondsString = seconds + "";
        while (minutesString.length() < 2) {
            minutesString = "0" + minutesString;
        }/*from   ww w  .j a v  a2  s .  com*/
        while (secondsString.length() < 2) {
            secondsString = "0" + secondsString;
        }
        return (hours == 0 ? "" : hoursString + ":") + minutesString + ":" + secondsString;
    }
}

Related

  1. formatStrDateTime(String stringDateTime)
  2. formatString(String agentId, long agentStartTime, long transactionSequence)
  3. formattedStats(String pExecTime, int pTxns)
  4. formattedUnixTime()
  5. formatTime(byte[] btValue, int iOffset, int iLength)
  6. formatTime(double totalTime)
  7. formatTime(final int timeSec)
  8. formatTime(final long time)
  9. formatTime(final long time)