Here you can find the source of elapsedTime(long timeInMs)
public static String elapsedTime(long timeInMs)
//package com.java2s; //License from project: Open Source License public class Main { public static String elapsedTime(long timeInMs) { String r;//from w ww. j ava 2 s. co m long time = (int) (timeInMs / 1000); long secs = time % 60 > 0 ? time % 60 : 0; time = time / 60; long mins = time % 60 > 0 ? time % 60 : 0; time = time / 60; long hours = time % 24 > 0 ? time % 24 : 0; long days = time / 24; r = String.valueOf(secs); String s = secs > 1 ? " seconds " : " second "; r = r + s; if (mins > 0) { String m = (mins > 1) ? " minutes " : " minute "; r = mins + m + r; } if (hours > 0) { String h = (hours > 1) ? " hours " : " hour "; r = hours + h + r; } if (days > 0) { String d = (days > 1) ? " days " : " day "; r = days + d + r; } return r; } }