Package org.springframework.boot.convert
Enum Class DurationStyle
- All Implemented Interfaces:
Serializable
,Comparable<DurationStyle>
,Constable
Duration format styles.
- Since:
- 2.0.0
- Author:
- Phillip Webb
-
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 DurationStyle
Detect the style from the given source value.static Duration
detectAndParse
(String value) Detect the style then parse the value to return a duration.static Duration
detectAndParse
(String value, ChronoUnit unit) Detect the style then parse the value to return a duration.protected final Matcher
protected final boolean
Parse the given value to a duration.abstract Duration
parse
(String value, ChronoUnit unit) Parse the given value to a duration.Print the specified duration.abstract String
print
(Duration value, ChronoUnit unit) Print the specified duration using the given unit.static DurationStyle
Returns the enum constant of this class with the specified name.static DurationStyle[]
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 '1s'. -
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 duration.- Parameters:
value
- the value to parse- Returns:
- a duration
-
parse
Parse the given value to a duration.- Parameters:
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)- Returns:
- a duration
-
print
Print the specified duration.- Parameters:
value
- the value to print- Returns:
- the printed result
-
print
Print the specified duration 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 duration.- Parameters:
value
- the value to parse- Returns:
- the parsed duration
- 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 duration.- Parameters:
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)- Returns:
- the parsed duration
- 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 duration style
- Throws:
IllegalArgumentException
- if the value is not a known style
-