Package org.springframework.boot.convert
Enum Class PeriodStyle
- All Implemented Interfaces:
Serializable
,Comparable<PeriodStyle>
,Constable
A standard set of
Period
units.- Since:
- 2.3.0
- Author:
- Eddú Meléndez, Edson Chávez, Valentine Wu
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic PeriodStyle
Detect the style from the given source value.static Period
detectAndParse
(String value) Detect the style then parse the value to return a period.static Period
detectAndParse
(String value, ChronoUnit unit) Detect the style then parse the value to return a period.protected final Matcher
protected boolean
Parse the given value to a Period.abstract Period
parse
(String value, ChronoUnit unit) Parse the given value to a period.Print the specified period.abstract String
print
(Period value, ChronoUnit unit) Print the specified period using the given unit.static PeriodStyle
Returns the enum constant of this class with the specified name.static PeriodStyle[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SIMPLE
Simple formatting, for example '1d'. -
ISO8601
ISO-8601 formatting.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
matches
-
matcher
-
parse
Parse the given value to a Period.- Parameters:
value
- the value to parse- Returns:
- a period
-
parse
Parse the given value to a period.- Parameters:
value
- the value to parseunit
- the period unit to use if the value doesn't specify one (null
will default to d)- Returns:
- a period
-
print
Print the specified period.- Parameters:
value
- the value to print- Returns:
- the printed result
-
print
Print the specified period using the given unit.- Parameters:
value
- the value to printunit
- the value to use for printing- Returns:
- the printed result
-
detectAndParse
Detect the style then parse the value to return a period.- Parameters:
value
- the value to parse- Returns:
- the parsed period
- Throws:
IllegalArgumentException
- if the value is not a known style or cannot be parsed
-
detectAndParse
Detect the style then parse the value to return a period.- Parameters:
value
- the value to parseunit
- the period unit to use if the value doesn't specify one (null
will default to ms)- Returns:
- the parsed period
- Throws:
IllegalArgumentException
- if the value is not a known style or cannot be parsed
-
detect
Detect the style from the given source value.- Parameters:
value
- the source value- Returns:
- the period style
- Throws:
IllegalArgumentException
- if the value is not a known style
-