ERXTimeDurationFormatter Class Reference

Inherits java::text::NumberFormat.

Collaboration diagram for ERXTimeDurationFormatter:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

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());

Author:
kieran

Constructor & Destructor Documentation

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.

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

ERXTimeDurationFormatter ( 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.


Member Function Documentation

StringBuffer format ( long  number,
StringBuffer  toAppendTo,
FieldPosition  fieldPosition 
)

StringBuffer format ( double  number,
StringBuffer  toAppendTo,
FieldPosition  pos 
)

Number parse ( String  source,
ParsePosition  parsePosition 
)

I know it is lame, but parsing is unsupported.

See also:
java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition)

String timePeriodDescription ( long  value,
boolean  showLargestUnitOnly,
boolean  omitSecondsPart 
) [private]

Parameters:
secondsValue 
resultIfNull 
showLargestUnitOnly rounded to the nearest hour, minute of second as appropriate
omitSecondsPart when the value is greater than one minute
Returns:
a user friendly description of a time duration seconds value


Member Data Documentation

final boolean _omitSecondsPart [private]

final boolean _showLargestUnitOnly [private]

final TimeUnit _timeUnit [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:12 2012 for Project Wonder by  doxygen 1.5.8