Here you can find the source of timeToString(final long time)
public static String timeToString(final long time)
//package com.java2s; //License from project: Open Source License public class Main { public static final long SECOND = 1000; public static final long MINUTE = SECOND * 60; public static final long HOUR = MINUTE * 60; public static final long DAY = HOUR * 24; public static String timeToString(final long time) { long timeRemaining = time; String timeString = ""; if (timeRemaining >= DAY) { final int days = (int) (timeRemaining / DAY); timeString = timeString.concat(days + (days == 1 ? " day " : " days ")); timeRemaining -= days * DAY; }//from ww w . j ava 2s . co m if (timeRemaining >= HOUR) { final int hours = (int) (timeRemaining / HOUR); timeString = timeString.concat(hours + (hours == 1 ? " hour " : " hours ")); timeRemaining -= hours * HOUR; } if (timeRemaining >= MINUTE) { final int minutes = (int) (timeRemaining / MINUTE); timeString = timeString.concat(minutes + (minutes == 1 ? " minute " : " minutes ")); timeRemaining -= minutes * MINUTE; } if (timeRemaining >= SECOND) { final int seconds = (int) (timeRemaining / SECOND); timeString = timeString.concat(seconds + (seconds == 1 ? " second " : " seconds ")); timeRemaining -= seconds * SECOND; } return timeString; } }