Java Time Format formatTime(int originalTime)

Here you can find the source of formatTime(int originalTime)

Description

format Time

License

Open Source License

Declaration

public static String formatTime(int originalTime) 

Method Source Code

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

public class Main {
    public static String formatTime(int originalTime) {
        int time = originalTime;
        int hours = (time - time % (60 * 60)) / 60 / 60;
        String hS = "" + hours;
        if (hours < 10)
            hS = "0" + hours;

        time = time - (hours * 60 * 60);
        int minutes = (time - time % 60) / 60;
        String mS = "" + minutes;
        if (minutes < 10)
            mS = "0" + minutes;

        time = time - (minutes * 60);/*  w  w w .j av a 2s . com*/
        int seconds = time;
        String sS = "" + seconds;
        if (seconds < 10)
            sS = "0" + seconds;

        String text = mS + ":" + sS;
        if (hours > 0)
            text = hS + ":" + text;

        return text;
    }
}

Related

  1. formatTime(final long time)
  2. formatTime(final long timeMS)
  3. formatTime(float seconds)
  4. formatTime(int minutes)
  5. formatTime(int minutes)
  6. formatTime(int seconds)
  7. formatTime(int seconds)
  8. formatTime(int seconds)
  9. formatTime(int secs)