public class DurationUtilImpl extends Object implements DurationUtil
DurationUtil
.Modifier and Type | Field and Description |
---|---|
private static DurationUtil |
instance |
Constructor and Description |
---|
DurationUtilImpl()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
appendSegment(StringBuilder buffer,
long segment,
boolean seconds) |
private String |
formatDuration(long duration,
long unitPerSeconds) |
String |
formatMilliseconds(long millis)
This method formats the given milliseconds as a human readable
String . |
String |
formatNanoseconds(long nanos)
This method formats the given nanoseconds as a human readable
String . |
String |
formatSeconds(long seconds)
This method formats the given seconds as a human readable
String . |
static DurationUtil |
getInstance()
This method gets the singleton instance of
DurationUtil . |
private static DurationUtil instance
public static DurationUtil getInstance()
DurationUtil
. Cdi.GET_INSTANCE
before using.public String formatNanoseconds(long nanos)
DurationUtil
String
.
nanos | formatNanoseconds(nanos) |
---|---|
1 | "0.000000001" |
61000000000 | "1:01" |
7141123456789" | "1:59:01.123456789" |
1234567890123456" | "14D06:47:07.890123456" |
formatNanoseconds
in interface DurationUtil
nanos
- is a duration in nanoseconds.public String formatMilliseconds(long millis)
DurationUtil
String
.
millis | formatMilliseconds(millis) |
---|---|
1 | "0.001" |
61000 | "1:01" |
7141123" | "1:59:01.123" |
1234567890" | "14D06:47:07.890" |
formatMilliseconds
in interface DurationUtil
millis
- is a duration in milliseconds.public String formatSeconds(long seconds)
DurationUtil
String
.
seconds | formatSeconds(seconds) |
---|---|
1 | "1" |
61 | "1:01" |
7141" | "1:59:01" |
1234567" | "14D06:56:07" |
formatSeconds
in interface DurationUtil
seconds
- is a duration in seconds.private String formatDuration(long duration, long unitPerSeconds)
duration
- is the duration to format.unitPerSeconds
- is the number of units per second (duration/unitsPerSecond
is the duration
in seconds).private void appendSegment(StringBuilder buffer, long segment, boolean seconds)
buffer
- is the StringBuilder
to append
to.segment
- is the segment to append (hours, minutes, or seconds).seconds
- - true
if segment are seconds, false
otherwise.Copyright © 2001–2016 mmm-Team. All rights reserved.