Here you can find the source of formatTime(int time)
public static String formatTime(int time)
//package com.java2s; //License from project: LGPL public class Main { private static final int SECONDS_PER_HOUR = 3600; private static final int MINUTES_PER_HOUR = 60; private static final int SECONDS_PER_MINUTE = 60; public static String formatTime(int time) { int hours = time / SECONDS_PER_HOUR; int minutes = (time - hours * SECONDS_PER_HOUR) / MINUTES_PER_HOUR; int seconds = time % SECONDS_PER_MINUTE; if (hours == 0) return padz(minutes + "", 2) + ":" + padz(seconds + "", 2); return hours + "h" + padz(minutes + "", 2); }/*from w w w. j a v a2 s . c o m*/ public static String padz(String s, int n) { String ns = "00000000" + s; return ns.substring(ns.length() - n); } }