public class TimeFormat extends Object
This class provides some utility functions useful to format elapsed time (usually given in milliseconds).
| Modifier and Type | Field and Description |
|---|---|
static long |
DAY_MS |
static long |
HOUR_MS |
static int |
LONG_FORMAT |
static long |
MIN_MS |
static long |
SEC_MS |
static int |
SHORT_FORMAT |
static long |
YEAR_MS |
| Constructor and Description |
|---|
TimeFormat() |
TimeFormat(int style) |
| Modifier and Type | Method and Description |
|---|---|
String |
format(long timeInMilliseconds)
This method takes the given number of milliseconds,
time, and creates a
new String containing a description of the time by means of days, hours, minutes and
seconds. |
static String |
formatLong(long timeInMillis) |
public static final int SHORT_FORMAT
public static final int LONG_FORMAT
public static final long SEC_MS
public static final long MIN_MS
public static final long HOUR_MS
public static final long DAY_MS
public static final long YEAR_MS
public String format(long timeInMilliseconds)
This method takes the given number of milliseconds, time, and creates a
new String containing a description of the time by means of days, hours, minutes and
seconds. If time is less than any of the mentioned properties, then this
field will not be printed, e.g.
format( 1000 ) will result in the string "1s" format( 90000 * 1000 ), i.e. milliseconds of one day + 1 hour, will
result in "1 day 1h".
This method is optimized over the old version (formatOld()
timeInMilliseconds - The time as an amount of milliseconds.public static String formatLong(long timeInMillis)
Copyright © 2015 jwall.org. All Rights Reserved.