public class ERXTimeDurationFormatter extends NumberFormat
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());
NumberFormat.FieldFRACTION_FIELD, INTEGER_FIELD| Constructor and Description |
|---|
ERXTimeDurationFormatter()
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.
|
ERXTimeDurationFormatter(TimeUnit timeUnit,
boolean showLargestUnitOnly,
boolean omitSecondsPart) |
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
format(double number,
StringBuffer toAppendTo,
FieldPosition pos) |
StringBuffer |
format(long number,
StringBuffer toAppendTo,
FieldPosition fieldPosition) |
Number |
parse(String source,
ParsePosition parsePosition)
I know it is lame, but parsing is unsupported.
|
clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingModeformat, formatToCharacterIterator, parseObjectpublic ERXTimeDurationFormatter()
public ERXTimeDurationFormatter(TimeUnit timeUnit)
timeUnit - the unit of time which is milliseconds, seconds, etc.public 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 toomitSecondsPart - imit the seconds unit from the format.public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
format in class NumberFormatpublic StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition fieldPosition)
format in class NumberFormatpublic Number parse(String source, ParsePosition parsePosition)
parse in class NumberFormatNumberFormat.parse(java.lang.String, java.text.ParsePosition)Copyright © 2002 – 2020 Project Wonder.