Here you can find the source of durationToString(long duration)
@SuppressWarnings("nls") private static String durationToString(long duration)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012, 2016 Andrew Gvozdev and others. * 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 * * Contributors:/*from w w w. j a v a 2 s. c om*/ * Andrew Gvozdev - initial API and implementation * IBM Corporation *******************************************************************************/ import java.util.concurrent.TimeUnit; public class Main { /** * Convert duration to human friendly format. */ @SuppressWarnings("nls") private static String durationToString(long duration) { String result = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); if (days > 0) { result += days + "d,"; } long hours = TimeUnit.MILLISECONDS.toHours(duration) % 24; if (hours > 0) { result += hours + "h:"; } long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) % 60; if (minutes > 0) { result += minutes + "m:"; } long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) % 60; if (seconds > 0) { result += seconds + "s."; } long milliseconds = TimeUnit.MILLISECONDS.toMillis(duration) % 1000; result += milliseconds + "ms"; return result; } }