Project Wonder 5.0

er.extensions.formatters
Class ERXTimeDurationFormatter

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by er.extensions.formatters.ERXTimeDurationFormatter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ERXTimeDurationFormatter
extends java.text.NumberFormat

User-presentable time duration format as days, hours, minutes and seconds. 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());

See Also:
Serialized Form
Author:
kieran

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
java.text.NumberFormat.Field
 
Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
ERXTimeDurationFormatter()
          Defaults to TimeUnit.SECONDS, showing all time units and showing seconds part of the time description.
ERXTimeDurationFormatter(java.util.concurrent.TimeUnit timeUnit)
          Defaults to showing all time units and showing seconds part of the time description.
ERXTimeDurationFormatter(java.util.concurrent.TimeUnit timeUnit, boolean showLargestUnitOnly, boolean omitSecondsPart)
           
 
Method Summary
 java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
           
 java.lang.StringBuffer format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)
           
 java.lang.Number parse(java.lang.String source, java.text.ParsePosition parsePosition)
          I know it is lame, but parsing is unsupported.
 
Methods inherited from class java.text.NumberFormat
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, setRoundingMode
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXTimeDurationFormatter

public ERXTimeDurationFormatter()
Defaults to TimeUnit.SECONDS, showing all time units and showing seconds part of the time description.


ERXTimeDurationFormatter

public ERXTimeDurationFormatter(java.util.concurrent.TimeUnit timeUnit)
Defaults to showing all time units and showing seconds part of the time description.

Parameters:
timeUnit - the unit of time which is milliseconds, seconds, etc.

ERXTimeDurationFormatter

public ERXTimeDurationFormatter(java.util.concurrent.TimeUnit timeUnit,
                                boolean showLargestUnitOnly,
                                boolean omitSecondsPart)
Parameters:
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.
Method Detail

format

public java.lang.StringBuffer format(double number,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
Specified by:
format in class java.text.NumberFormat

format

public java.lang.StringBuffer format(long number,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition fieldPosition)
Specified by:
format in class java.text.NumberFormat

parse

public java.lang.Number parse(java.lang.String source,
                              java.text.ParsePosition parsePosition)
I know it is lame, but parsing is unsupported.

Specified by:
parse in class java.text.NumberFormat
See Also:
NumberFormat.parse(java.lang.String, java.text.ParsePosition)

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.