Here you can find the source of formatTime2(long secs)
public static String formatTime2(long secs)
//package com.java2s; //License from project: Artistic License public class Main { public static String formatTime2(long secs) { StringBuffer rv = new StringBuffer(); int seconds = (int) secs, minutes = 0, hours = 0, days = 0; days = seconds / (60 * 60 * 24); hours = seconds / (60 * 60) % 24; minutes = (seconds / 60) % 60;// www.ja va2 s . c om seconds = seconds % 60; if (days > 0) { rv.append(days); rv.append(":"); } if (hours > 0) { if (hours < 10) rv.append("0"); rv.append(hours); rv.append(":"); } if (minutes > 0) { if (minutes < 10) rv.append("0"); rv.append(minutes); rv.append(":"); } if (seconds < 10) rv.append("0"); rv.append(seconds); return rv.toString(); } }