public enum PeriodStyle extends java.lang.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(java.lang.String value)
Detect the style from the given source value.
|
static java.time.Period |
detectAndParse(java.lang.String value)
Detect the style then parse the value to return a period.
|
static java.time.Period |
detectAndParse(java.lang.String value,
java.time.temporal.ChronoUnit unit)
Detect the style then parse the value to return a period.
|
protected java.util.regex.Matcher |
matcher(java.lang.String value) |
protected boolean |
matches(java.lang.String value) |
java.time.Period |
parse(java.lang.String value)
Parse the given value to a Period.
|
abstract java.time.Period |
parse(java.lang.String value,
java.time.temporal.ChronoUnit unit)
Parse the given value to a period.
|
java.lang.String |
print(java.time.Period value)
Print the specified period.
|
abstract java.lang.String |
print(java.time.Period value,
java.time.temporal.ChronoUnit unit)
Print the specified period using the given unit.
|
static PeriodStyle |
valueOf(java.lang.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(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 boolean matches(java.lang.String value)
protected final java.util.regex.Matcher matcher(java.lang.String value)
public java.time.Period parse(java.lang.String value)
value
- the value to parsepublic abstract java.time.Period parse(java.lang.String value, java.time.temporal.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 java.lang.String print(java.time.Period value)
value
- the value to printpublic abstract java.lang.String print(java.time.Period value, java.time.temporal.ChronoUnit unit)
value
- the value to printunit
- the value to use for printingpublic static java.time.Period 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.Period detectAndParse(java.lang.String value, java.time.temporal.ChronoUnit unit)
value
- the value to parseunit
- the period 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 PeriodStyle detect(java.lang.String value)
value
- the source valuejava.lang.IllegalArgumentException
- if the value is not a known style