Java TimeUnit Format formatDuration(long time, TimeUnit unit)

Here you can find the source of formatDuration(long time, TimeUnit unit)

Description

Formats a String duration property (time + optional unit).

License

Open Source License

Declaration

public static String formatDuration(long time, TimeUnit unit) 

Method Source Code

//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();
    }
}

Related

  1. format(final long duration, final TimeUnit sourceUnit, final TimeUnit min)
  2. formatHighest(long duration, final TimeUnit max)
  3. formatMillis(long duration, TimeUnit max, TimeUnit min, boolean useAbbreviation)
  4. formatMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit)
  5. formatTime(long dt, TimeUnit input, TimeUnit output, int decimalPlaces)