Here you can find the source of formatUptime(long uptimeInMs)
public static String formatUptime(long uptimeInMs)
//package com.java2s; /* This file is part of VoltDB. * Copyright (C) 2008-2015 VoltDB Inc./*w w w . j a v a 2 s . co m*/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * 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 * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with VoltDB. If not, see <http://www.gnu.org/licenses/>. */ import java.util.concurrent.TimeUnit; public class Main { public static String formatUptime(long uptimeInMs) { long remainingMs = uptimeInMs; long days = TimeUnit.MILLISECONDS.toDays(remainingMs); remainingMs -= TimeUnit.DAYS.toMillis(days); long hours = TimeUnit.MILLISECONDS.toHours(remainingMs); remainingMs -= TimeUnit.HOURS.toMillis(hours); long minutes = TimeUnit.MILLISECONDS.toMinutes(remainingMs); remainingMs -= TimeUnit.MINUTES.toMillis(minutes); long seconds = TimeUnit.MILLISECONDS.toSeconds(remainingMs); remainingMs -= TimeUnit.SECONDS.toMillis(seconds); return String.format("%d days %02d:%02d:%02d.%03d", days, hours, minutes, seconds, remainingMs); } }