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 SummaryConstructorsConstructorDescriptionCreate aDurationFormatterin a specificDurationFormat.Style.DurationFormatter(DurationFormat.Style style, @Nullable DurationFormat.Unit defaultUnit) 
- 
Method Summary
- 
Constructor Details- 
DurationFormatterCreate aDurationFormatterin a specificDurationFormat.Style.When a unit is needed but cannot be determined (for example, printing a Duration in the SIMPLEstyle),DurationFormat.Unit#MILLISis used.
- 
DurationFormatterCreate 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- the- DurationStyleto use
- defaultUnit- the- DurationFormat.Unitto fall back to when parsing and printing
 
 
- 
- 
Method Details- 
parseDescription copied from interface:ParserParse a text String to produce a T.- Specified by:
- parsein interface- Parser<Duration>
- Parameters:
- text- the text string
- locale- the current user locale
- Returns:
- an instance of T
- Throws:
- ParseException- when a parse exception occurs in a java.text parsing library
 
- 
printDescription copied from interface:PrinterPrint the object of type T for display.
 
-