Here you can find the source of formatTime(Integer seconds)
public static String formatTime(Integer seconds)
//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"; } } }