Java Time Format formatTime(Integer seconds)

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

Description

format Time

License

Apache License

Declaration

public static String formatTime(Integer seconds) 

Method Source Code

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

public class Main {
    public static String formatTime(Integer seconds) {
        Integer hours = seconds / 3600;
        Integer remainder = seconds % 3600;
        Integer mins = remainder / 60;
        Integer secs = remainder % 60;
        if (hours > 0) {
            return hours + ":" + mins + ":" + secs + " hours";
        } else if (mins > 0) {
            if (secs < 10) {
                return mins + ":0" + secs + " minutes";
            }/*  www.j a v  a 2  s .  c o  m*/
            if (secs == 00) {
                return mins.toString() + " minutes";
            } else
                return mins + ":" + secs + " minutes";

        } else {
            return secs.toString() + " seconds";
        }
    }
}

Related

  1. formatTime(int time)
  2. formatTime(int time)
  3. formatTime(int time)
  4. formatTime(int value)
  5. formatTime(Integer hour, Integer minute, Integer second, Integer ampm, Integer zoneOffset)
  6. formatTime(long dtNanos)
  7. formatTime(long elapsedTime)
  8. formatTime(long elapsedTime)
  9. formatTime(long millis)