Class DurationFormatter
java.lang.Object
org.springframework.format.datetime.standard.DurationFormatter
-
Constructor summary
ConstructorsConstructorDescriptionDurationFormatter(DurationFormat.style style) Create aDurationFormatterin a specificDurationFormat.style.DurationFormatter(DurationFormat.style style, @Nullable DurationFormat.Unit defaultUnit) -
Method summary
-
Constructor Details
-
DurationFormatter
Create 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. -
DurationFormatter
public DurationFormatter(DurationFormat.style style, @Nullable DurationFormat.Unit defaultUnit) 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:
parse in interface Parser<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.
-