Java Time Format formatTime(int seconds)

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

Description

format Time

License

Open Source License

Declaration

public static String formatTime(int seconds) 

Method Source Code

//package com.java2s;

public class Main {
    public static String formatTime(int seconds) {

        if (seconds >= 3600) {

            return (seconds / 3600) + ":" + ((seconds % 3600) <= 9 ? "0" + (seconds % 3600) + ":" + (seconds - 3600)
                    : (seconds % 3600) + ":" + (seconds - 3600));

        } else if (seconds >= 60) {

            return (seconds / 60 + ":" + ((seconds % 60) <= 9 ? "0" + (seconds % 60) : (seconds % 60)));

        } else {//from  w ww .j a  va2  s.  c  o m

            return seconds + "";

        }

    }
}

Related

  1. formatTime(int minutes)
  2. formatTime(int minutes)
  3. formatTime(int originalTime)
  4. formatTime(int seconds)
  5. formatTime(int seconds)
  6. formatTime(int secs)
  7. formatTime(int time)
  8. formatTime(int time)
  9. formatTime(int time)