
Public Member Functions | |
| ERXTimeDurationFormatter (TimeUnit timeUnit, boolean showLargestUnitOnly, boolean omitSecondsPart) | |
| ERXTimeDurationFormatter (TimeUnit timeUnit) | |
| ERXTimeDurationFormatter () | |
| StringBuffer | format (long number, StringBuffer toAppendTo, FieldPosition fieldPosition) |
| StringBuffer | format (double number, StringBuffer toAppendTo, FieldPosition pos) |
| Number | parse (String source, ParsePosition parsePosition) |
Private Member Functions | |
| String | timePeriodDescription (long value, boolean showLargestUnitOnly, boolean omitSecondsPart) |
Private Attributes | |
| final boolean | _omitSecondsPart |
| final boolean | _showLargestUnitOnly |
| final TimeUnit | _timeUnit |
Usage example: StopWatch w = new StopWatch(); w.start(); ... perform long task ... w.stop(); ERXTimeDurationFormatter f = new ERXTimeDurationFormatter(TimeUnit.MILLISECONDS);
String message = "The task took " + f.format(w.getTime());
Defaults to TimeUnit.SECONDS, showing all time units and showing seconds part of the time description.
| ERXTimeDurationFormatter | ( | TimeUnit | timeUnit | ) |
Defaults to showing all time units and showing seconds part of the time description.
| timeUnit | the unit of time which is milliseconds, seconds, etc. |
| ERXTimeDurationFormatter | ( | TimeUnit | timeUnit, | |
| boolean | showLargestUnitOnly, | |||
| boolean | omitSecondsPart | |||
| ) |
| timeUnit | the unit of time which is milliseconds, seconds, etc. | |
| showLargestUnitOnly | display the largest time unit (days, hours, minutes or seconds) that the time value rounds down to | |
| omitSecondsPart | imit the seconds unit from the format. |
| StringBuffer format | ( | long | number, | |
| StringBuffer | toAppendTo, | |||
| FieldPosition | fieldPosition | |||
| ) |
| StringBuffer format | ( | double | number, | |
| StringBuffer | toAppendTo, | |||
| FieldPosition | pos | |||
| ) |
I know it is lame, but parsing is unsupported.
| String timePeriodDescription | ( | long | value, | |
| boolean | showLargestUnitOnly, | |||
| boolean | omitSecondsPart | |||
| ) | [private] |
| secondsValue | ||
| resultIfNull | ||
| showLargestUnitOnly | rounded to the nearest hour, minute of second as appropriate | |
| omitSecondsPart | when the value is greater than one minute |
final boolean _omitSecondsPart [private] |
final boolean _showLargestUnitOnly [private] |
final TimeUnit _timeUnit [private] |
1.5.8