Here you can find the source of formatElapsedSecs(long secs)
Parameter | Description |
---|---|
secs | Elapsed seconds |
public static String formatElapsedSecs(long secs)
//package com.java2s; /**/* w w w . j ava2s.co m*/ * Oshi (https://github.com/dblock/oshi) * * Copyright (c) 2010 - 2016 The Oshi Project Team * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Maintainers: * dblock[at]dblock[dot]org * widdis[at]gmail[dot]com * enrico.bianchi[at]gmail[dot]com * * Contributors: * https://github.com/dblock/oshi/graphs/contributors */ import java.util.concurrent.TimeUnit; public class Main { /** * Formats an elapsed time in seconds as days, hh:mm:ss. * * @param secs * Elapsed seconds * @return A string representation of elapsed time */ public static String formatElapsedSecs(long secs) { long eTime = secs; final long days = TimeUnit.SECONDS.toDays(eTime); eTime -= TimeUnit.DAYS.toSeconds(days); final long hr = TimeUnit.SECONDS.toHours(eTime); eTime -= TimeUnit.HOURS.toSeconds(hr); final long min = TimeUnit.SECONDS.toMinutes(eTime); eTime -= TimeUnit.MINUTES.toSeconds(min); final long sec = eTime; return String.format("%d days, %02d:%02d:%02d", days, hr, min, sec); } }