Java Second secondToString(long second)

Here you can find the source of secondToString(long second)

Description

second To String

License

Apache License

Declaration

public static String secondToString(long second) 

Method Source Code

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

public class Main {
    public static String secondToString(long second) {

        long sec = second % 60;
        second = second / 60;//  w  w w  . ja  v a2 s  . c  o m
        long min = second % 60;
        long hour = second = second / 60;

        String nowTime = new String();

        if (hour < 10) {
            if (hour == 0)
                nowTime = "00";
            nowTime = "0" + hour;
        } else {
            nowTime = Long.toString(hour);
        }

        if (min < 10) {
            nowTime = nowTime + ":0" + min;
        } else {
            nowTime = nowTime + ":" + min;
        }

        if (sec < 10) {
            nowTime = nowTime + ":0" + sec;
        } else {
            nowTime = nowTime + ":" + sec;
        }

        return nowTime;
    }
}

Related

  1. seconds(int seconds)
  2. secondsAfterMidnightToClock(int secondsAfterMidnight)
  3. secondsAgo(int seconds)
  4. secondsFromBeginningOfBoardcastEpoch()
  5. secondsSince(final long since)
  6. stringToSeconds(String string)
  7. strTimeToSeconds(String hmsTimes)
  8. ticksToSeconds(long ticks)
  9. ticksWithSecondsSetTo(long ticks, int seconds)