Here you can find the source of formatDuration(long time, TimeUnit unit)
public static String formatDuration(long time, TimeUnit unit)
//package com.java2s; /*-/*from w ww . java2 s .c om*/ * See the file LICENSE for redistribution information. * * Copyright (c) 2002-2010 Oracle. All rights reserved. * */ import java.util.concurrent.TimeUnit; public class Main { /** * Formats a String duration property (time + optional unit). * value in millis. */ public static String formatDuration(long time, TimeUnit unit) { return String.valueOf(time) + ' ' + unit.name(); } }