Class DurationFormatter
java.lang.Object
org.springframework.format.datetime.standard.DurationFormatter
-
Constructor Summary
ConstructorsConstructorDescriptionCreate 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
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
-