枚举 DurationStyle
- java.lang.Object
- java.lang.Enum<DurationStyle>
- org.springframework.boot.convert.DurationStyle
- 所有已实现的接口:
Serializable
,Comparable<DurationStyle>
public enum DurationStyle extends Enum<DurationStyle>
Duration format styles.- 从以下版本开始:
- 2.0.0
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 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)
返回带有指定名称的该类型的枚举常量。static DurationStyle[]
values()
按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。
枚举常量详细资料
SIMPLE
public static final DurationStyle SIMPLE
Simple formatting, for example '1s'.
ISO8601
public static final DurationStyle ISO8601
ISO-8601 formatting.
方法详细资料
values
public static DurationStyle[] values()
按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。该方法可用于迭代 常量, 如下所示:for (DurationStyle c : DurationStyle.values()) System.out.println(c);
- 返回:
- 按照声明该枚举类型的常量的顺序返回的包含这些常量的数组
valueOf
public static DurationStyle valueOf(String name)
返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)- 参数:
name
- 要返回的枚举常量的名称。- 返回:
- 返回带有指定名称的枚举常量
- 抛出:
IllegalArgumentException
- 如果该枚举类型没有带有指定名称的常量NullPointerException
- 如果参数为空值
parse
public Duration parse(String value)
Parse the given value to a duration.- 参数:
value
- the value to parse- 返回:
- a duration
parse
public abstract Duration parse(String value, ChronoUnit unit)
Parse the given value to a duration.- 参数:
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)- 返回:
- a duration
print
public String print(Duration value)
Print the specified duration.- 参数:
value
- the value to print- 返回:
- the printed result
print
public abstract String print(Duration value, ChronoUnit unit)
Print the specified duration using the given unit.- 参数:
value
- the value to printunit
- the value to use for printing- 返回:
- the printed result
detectAndParse
public static Duration detectAndParse(String value)
Detect the style then parse the value to return a duration.- 参数:
value
- the value to parse- 返回:
- the parsed duration
- 抛出:
IllegalStateException
- if the value is not a known style or cannot be parsed
detectAndParse
public static Duration detectAndParse(String value, ChronoUnit unit)
Detect the style then parse the value to return a duration.- 参数:
value
- the value to parseunit
- the duration unit to use if the value doesn't specify one (null
will default to ms)- 返回:
- the parsed duration
- 抛出:
IllegalStateException
- if the value is not a known style or cannot be parsed
detect
public static DurationStyle detect(String value)
Detect the style from the given source value.- 参数:
value
- the source value- 返回:
- the duration style
- 抛出:
IllegalStateException
- if the value is not a known style