Here you can find the source of elapsedTime(long ms)
public static String elapsedTime(long ms)
//package com.java2s; /* Copyright (C) 2009 Mobile Sorcery AB /*from w w w . j a v a2 s .com*/ This program is free software; you can redistribute it and/or modify it under the terms of the Eclipse Public License v1.0. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License v1.0 for more details. You should have received a copy of the Eclipse Public License v1.0 along with this program. It is also available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { public static String elapsedTime(long ms) { String unit = "ms"; long value = ms; long rem = 0; if (ms >= 3600000) { unit = "h"; value = ms / 3600000; rem = ms % 3600000; } else if (ms >= 60000) { unit = "m"; value = ms / 60000; rem = ms % 60000; } else if (ms >= 1000) { unit = "s"; value = ms / 1000; rem = ms % 1000; } String minor = rem == 0 ? "" : " " + elapsedTime(rem); return value + unit + minor; } }