FormatUtil { public static String formatElapsedSecs(long secs) { long eTime = secs; final long days = TimeUnit.SECONDS.toDays(eTime); eTime -= TimeUnit.DAYS.toSeconds(days); final long hr = TimeUnit.SECONDS.toHours(eTime); eTime -= TimeUnit.HOURS.toSeconds(hr); final long min = TimeUnit.SECONDS.toMinutes(eTime); eTime -= TimeUnit.MINUTES.toSeconds(min); final long sec = eTime; return String.format("%d days, %02d:%02d:%02d", days, hr, min, sec); } private  FormatUtil(); static String formatBytes(long bytes); static String formatBytesDecimal(long bytes); static String formatHertz(long hertz); static String formatValue(long value, String unit); static String formatElapsedSecs(long secs); static float round(float d, int decimalPlace); static long getUnsignedInt(int x); static String toUnsignedString(int i); static String toUnsignedString(long l); static String formatError(int errorCode); static final String HEX_ERROR; }
@Test public void testFormatElapsedSecs() { assertEquals("0 days, 00:00:00", FormatUtil.formatElapsedSecs(0)); assertEquals("0 days, 03:25:45", FormatUtil.formatElapsedSecs(12345)); assertEquals("1 days, 10:17:36", FormatUtil.formatElapsedSecs(123456)); assertEquals("14 days, 06:56:07", FormatUtil.formatElapsedSecs(1234567)); }