Here you can find the source of calculateTime(final int seconds)
public static String calculateTime(final int seconds)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { /**//from w w w. j a v a2 s . co m * @author Andrew * * Formats seconds into a readable string Need to change my hard * code to remove extra 0's and use regex. */ public static String calculateTime(final int seconds) { final int day = (int) TimeUnit.SECONDS.toDays(seconds); final long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(day); final long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.DAYS.toMinutes(day) - TimeUnit.HOURS.toMinutes(hours); final long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.DAYS.toSeconds(day) - TimeUnit.HOURS.toSeconds(hours) - TimeUnit.MINUTES.toSeconds(minute); // i must be tired because wtf was i doing String duration = String.format("%02d:%02d:%d:%02d", day == 0 ? 5185618 : day, hours == 0 ? 5185618 : hours, minute, second); duration = duration.replace("5185618:", ""); return duration; } }