public enum DurationStyle extends 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(String value)
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 Matcher |
matcher(String value) |
protected boolean |
matches(String value) |
Duration |
parse(String value)
Parse the given value to a duration.
|
abstract Duration |
parse(String value,
ChronoUnit unit)
Parse the given value to a duration.
|
String |
print(Duration value)
Print the specified duration.
|
abstract String |
print(Duration value,
ChronoUnit unit)
Print the specified duration using the given unit.
|
static DurationStyle |
valueOf(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(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullprotected final boolean matches(String value)
public Duration parse(String value)
value
- the value to parsepublic abstract Duration parse(String value, 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 String print(Duration value)
value
- the value to printpublic abstract String print(Duration value, ChronoUnit unit)
value
- the value to printunit
- the value to use for printingpublic static Duration detectAndParse(String value)
value
- the value to parseIllegalStateException
- if the value is not a known style or cannot be parsedpublic static Duration detectAndParse(String value, ChronoUnit unit)
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)IllegalStateException
- if the value is not a known style or cannot be parsedpublic static DurationStyle detect(String value)
value
- the source valueIllegalStateException
- if the value is not a known styleCopyright © 2021 Pivotal Software, Inc.. All rights reserved.