Enum Class PeriodStyle

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

public enum PeriodStyle extends Enum<PeriodStyle>
A standard set of Period units.
Since:
2.3.0
Author:
Eddú Meléndez, Edson Chávez
See Also:
  • Enum Constant Details

    • SIMPLE

      public static final PeriodStyle SIMPLE
      Simple formatting, for example '1d'.
    • ISO8601

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

    • values

      public static PeriodStyle[] 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 PeriodStyle 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 boolean matches(String value)
    • matcher

      protected final Matcher matcher(String value)
    • parse

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

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

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

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

      public static Period detectAndParse(String value)
      Detect the style then parse the value to return a period.
      Parameters:
      value - the value to parse
      Returns:
      the parsed period
      Throws:
      IllegalArgumentException - if the value is not a known style or cannot be parsed
    • detectAndParse

      public static Period detectAndParse(String value, ChronoUnit unit)
      Detect the style then parse the value to return a period.
      Parameters:
      value - the value to parse
      unit - the period unit to use if the value doesn't specify one (null will default to ms)
      Returns:
      the parsed period
      Throws:
      IllegalArgumentException - if the value is not a known style or cannot be parsed
    • detect

      public static PeriodStyle detect(String value)
      Detect the style from the given source value.
      Parameters:
      value - the source value
      Returns:
      the period style
      Throws:
      IllegalArgumentException - if the value is not a known style