Here you can find the source of formatTime3(long secs)
public static String formatTime3(long secs)
//package com.java2s; //License from project: Artistic License public class Main { public static String formatTime3(long secs) { int seconds = (int) secs; int minutes = 0; int hours = 0; int days = 0; days = seconds / (60 * 60 * 24); hours = seconds / (60 * 60) % 24; minutes = (seconds / 60) % 60;/*from w ww . j a v a 2 s . co m*/ seconds %= 60; StringBuffer buf = new StringBuffer(); if (days > 0) buf.append(days).append(days != 1 ? " days, " : " day, "); if (days > 0 || hours > 0) buf.append(hours).append(hours != 1 ? " hours, " : " hour, "); if (hours > 0 || minutes > 0) buf.append(minutes).append(minutes != 1 ? " minutes, " : " minute, "); buf.append(seconds).append(seconds != 1 ? " seconds" : " second"); return buf.toString(); } }