Enum Class DurationStyle

java.lang.Object
java.lang.Enum<DurationStyle>
org.springframework.boot.convert.DurationStyle
All Implemented Interfaces:
Serializable, Comparable<DurationStyle>, Constable

public enum DurationStyle extends Enum<DurationStyle>
Duration format styles.
Since:
2.0.0
Author:
Phillip Webb
  • Enum Constant Details

    • SIMPLE

      public static final DurationStyle SIMPLE
      Simple formatting, for example '1s'.
    • ISO8601

      public static final DurationStyle ISO8601
      ISO-8601 formatting.
  • Method Details

    • values

      public static DurationStyle[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DurationStyle valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • matches

      protected final boolean matches(String value)
    • matcher

      protected final Matcher matcher(String value)
    • parse

      public Duration parse(String value)
      Parse the given value to a duration.
      Parameters:
      value - the value to parse
      Returns:
      a duration
    • parse

      public abstract Duration parse(String value, ChronoUnit unit)
      Parse the given value to a duration.
      Parameters:
      value - the value to parse
      unit - the duration unit to use if the value doesn't specify one (null will default to ms)
      Returns:
      a duration
    • print

      public String print(Duration value)
      Print the specified duration.
      Parameters:
      value - the value to print
      Returns:
      the printed result
    • print

      public abstract String print(Duration value, ChronoUnit unit)
      Print the specified duration using the given unit.
      Parameters:
      value - the value to print
      unit - the value to use for printing
      Returns:
      the printed result
    • detectAndParse

      public static Duration detectAndParse(String value)
      Detect the style then parse the value to return a duration.
      Parameters:
      value - the value to parse
      Returns:
      the parsed duration
      Throws:
      IllegalArgumentException - 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.
      Parameters:
      value - the value to parse
      unit - the duration unit to use if the value doesn't specify one (null will default to ms)
      Returns:
      the parsed duration
      Throws:
      IllegalArgumentException - 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.
      Parameters:
      value - the source value
      Returns:
      the duration style
      Throws:
      IllegalArgumentException - if the value is not a known style