Java Second Convert secondsToString(int seconds)

Here you can find the source of secondsToString(int seconds)

Description

seconds To String

License

Apache License

Parameter

Parameter Description
time a parameter
fmt a parameter

Declaration

static public String secondsToString(int seconds) 

Method Source Code

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

public class Main {
    /**//www  . java 2 s  . c o m
     * @param time
     * @param fmt
     */
    static public String secondsToString(int seconds) {
        int h = seconds / (60 * 60);
        int m = seconds / 60 % 60;
        int s = seconds % 60;
        return toStr2(h) + ":" + toStr2(m) + (s == 0 ? "" : ":" + toStr2(s));
    }

    final static private String toStr2(int x) {
        return x < 10 ? "0" + x : "" + x;
    }
}

Related

  1. secondsToHours(double seconds)
  2. secondsToHours(int s)
  3. secondsToInternal(int seconds)
  4. secondsToNanoseconds(long seconds)
  5. secondsToReadableBiggest(int seconds)
  6. secondsToString(long seconds)
  7. SecondsToString(long seconds)
  8. secondsToString(long seconds)
  9. secondsToString(long time)