Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String intTimeToString(int secs) { StringBuilder sb = new StringBuilder(); int[] hourMinSec = new int[3]; hourMinSec[0] = secs / 3600; hourMinSec[1] = (secs - hourMinSec[0] * 3600) / 60; hourMinSec[2] = secs - hourMinSec[0] * 3600 - hourMinSec[1] * 60; for (int i = 0; i < hourMinSec.length; i++) { if (i == hourMinSec.length - 1 && hourMinSec[i] == 0) continue; if (i > 0) sb.append(":"); sb.append(hourMinSec[i] >= 10 ? hourMinSec[i] : ("0" + hourMinSec[i])); } return sb.toString(); } }