Here you can find the source of formatTime(Long num)
public static String formatTime(Long num)
//package com.java2s; /* This file is part of Catacombs. // w ww.j a v a 2 s . c o m Catacombs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Catacombs 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Catacombs. If not, see <http://www.gnu.org/licenses/>. * * @author John Keay <>(@Steeleyes, @Blockhead2) * @copyright Copyright (C) 2011 * @license GNU GPL <http://www.gnu.org/licenses/> */ public class Main { public static String formatTime(Long num) { if (num <= 0) return "never"; String str = ""; num = num / 1000; if (num >= 60 * 60 * 24) { int d = (int) (num / (60 * 60 * 24)); str += d + "d"; num = num - (d * 60 * 60 * 24); } if (num >= 60 * 60) { int d = (int) (num / (60 * 60)); str += d + "h"; num = num - (d * 60 * 60); } if (num >= 60) { int d = (int) (num / (60)); str += d + "m"; num = num - (d * 60); } if (num > 0) str += num + "s"; return str; } }