public enum PeriodStyle extends Enum<PeriodStyle>
Period
units.Period
Enum Constant and Description |
---|
ISO8601
ISO-8601 formatting.
|
SIMPLE
Simple formatting, for example '1d'.
|
Modifier and Type | Method and Description |
---|---|
static PeriodStyle |
detect(String value)
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 Matcher |
matcher(String value) |
protected boolean |
matches(String value) |
Period |
parse(String value)
Parse the given value to a Period.
|
abstract Period |
parse(String value,
ChronoUnit unit)
Parse the given value to a period.
|
String |
print(Period value)
Print the specified period.
|
abstract String |
print(Period value,
ChronoUnit unit)
Print the specified period using the given unit.
|
static PeriodStyle |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static PeriodStyle[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PeriodStyle SIMPLE
public static final PeriodStyle ISO8601
public static PeriodStyle[] values()
for (PeriodStyle c : PeriodStyle.values()) System.out.println(c);
public static PeriodStyle 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 boolean matches(String value)
public Period parse(String value)
value
- the value to parsepublic abstract Period parse(String value, ChronoUnit unit)
value
- the value to parseunit
- the period unit to use if the value doesn't specify one (null
will default to d)public String print(Period value)
value
- the value to printpublic abstract String print(Period value, ChronoUnit unit)
value
- the value to printunit
- the value to use for printingpublic static Period detectAndParse(String value)
value
- the value to parseIllegalArgumentException
- if the value is not a known style or cannot be
parsedpublic static Period detectAndParse(String value, ChronoUnit unit)
value
- the value to parseunit
- the period unit to use if the value doesn't specify one (null
will default to ms)IllegalArgumentException
- if the value is not a known style or cannot be
parsedpublic static PeriodStyle detect(String value)
value
- the source valueIllegalArgumentException
- if the value is not a known style