Here you can find the source of formatTime(long time)
public static String formatTime(long time)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { public static String formatTime(long time) { long days = TimeUnit.SECONDS.toDays(time) % 30; long hours = TimeUnit.SECONDS.toHours(time) % 24; long minutes = TimeUnit.SECONDS.toMinutes(time) % 60; long seconds = TimeUnit.SECONDS.toSeconds(time) % 60; return (days == 0L) ? String.format("%d hours, %d minutes; and %d seconds", hours, minutes, seconds) : String.format("%d days, %d hours, %d minutes; and %d seconds", days, hours, minutes, seconds); }/*from w ww. j a v a 2 s . c om*/ }