public enum DurationStyle extends java.lang.Enum<DurationStyle>
Enum Constant and Description |
---|
ISO8601
ISO-8601 formatting.
|
SIMPLE
Simple formatting, for example '1s'.
|
Modifier and Type | Method and Description |
---|---|
static DurationStyle |
detect(java.lang.String value)
Detect the style from the given source value.
|
static java.time.Duration |
detectAndParse(java.lang.String value)
Detect the style then parse the value to return a duration.
|
static java.time.Duration |
detectAndParse(java.lang.String value,
java.time.temporal.ChronoUnit unit)
Detect the style then parse the value to return a duration.
|
protected java.util.regex.Matcher |
matcher(java.lang.String value) |
protected boolean |
matches(java.lang.String value) |
java.time.Duration |
parse(java.lang.String value)
Parse the given value to a duration.
|
abstract java.time.Duration |
parse(java.lang.String value,
java.time.temporal.ChronoUnit unit)
Parse the given value to a duration.
|
java.lang.String |
print(java.time.Duration value)
Print the specified duration.
|
abstract java.lang.String |
print(java.time.Duration value,
java.time.temporal.ChronoUnit unit)
Print the specified duration using the given unit.
|
static DurationStyle |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static DurationStyle[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DurationStyle SIMPLE
public static final DurationStyle ISO8601
public static DurationStyle[] values()
for (DurationStyle c : DurationStyle.values()) System.out.println(c);
public static DurationStyle valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullprotected final boolean matches(java.lang.String value)
protected final java.util.regex.Matcher matcher(java.lang.String value)
public java.time.Duration parse(java.lang.String value)
value
- the value to parsepublic abstract java.time.Duration parse(java.lang.String value, java.time.temporal.ChronoUnit unit)
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)public java.lang.String print(java.time.Duration value)
value
- the value to printpublic abstract java.lang.String print(java.time.Duration value, java.time.temporal.ChronoUnit unit)
value
- the value to printunit
- the value to use for printingpublic static java.time.Duration detectAndParse(java.lang.String value)
value
- the value to parsejava.lang.IllegalArgumentException
- if the value is not a known style or cannot be
parsedpublic static java.time.Duration detectAndParse(java.lang.String value, java.time.temporal.ChronoUnit unit)
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)java.lang.IllegalArgumentException
- if the value is not a known style or cannot be
parsedpublic static DurationStyle detect(java.lang.String value)
value
- the source valuejava.lang.IllegalArgumentException
- if the value is not a known style