Class DurationFormatter
java.lang.Object
org.springframework.format.datetime.standard.DurationFormatter
Formatter implementation for a JSR-310 Duration,
 following JSR-310's parsing rules for a Duration by default and
 supporting additional DurationFormat.Style styles.- Since:
 - 6.2
 - Author:
 - Juergen Hoeller
 - See Also:
 
- 
Constructor Summary
ConstructorsConstructorDescriptionCreate aDurationFormatterin a specificDurationFormat.Style.DurationFormatter(DurationFormat.Style style, DurationFormat.Unit defaultUnit)  - 
Method Summary
 
- 
Constructor Details
- 
DurationFormatter
Create aDurationFormatterin a specificDurationFormat.Style.When a unit is needed but cannot be determined (e.g. printing a Duration in the
SIMPLEstyle),DurationFormat.Unit#MILLISis used. - 
DurationFormatter
Create aDurationFormatterin a specificDurationFormat.Stylewith an optionalDurationFormat.Unit.If a
defaultUnitis specified, it may be used in parsing cases when no unit is present in the string (provided the style allows for such a case). It will also be used as the representation's resolution when printing in theDurationFormat.Style.SIMPLEstyle. Otherwise, the style defines its default unit.- Parameters:
 style- theDurationStyleto usedefaultUnit- theDurationFormat.Unitto fall back to when parsing and printing
 
 - 
 - 
Method Details
- 
parse
Description copied from interface:ParserParse a text String to produce a T.- Specified by:
 parsein interfaceParser<Duration>- Parameters:
 text- the text stringlocale- the current user locale- Returns:
 - an instance of T
 - Throws:
 ParseException- when a parse exception occurs in a java.text parsing library
 - 
print
Description copied from interface:PrinterPrint the object of type T for display. 
 -