org.springframework.boot.convert

Enum PeriodStyle

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


    public enum PeriodStyle
    extends java.lang.Enum<PeriodStyle>
    A standard set of Period units.
    Since:
    2.3.0
    See Also:
    Period
    • Enum Constant Summary

      Enum Constants 
      Enum Constant and Description
      ISO8601
      ISO-8601 formatting.
      SIMPLE
      Simple formatting, for example '1d'.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • SIMPLE

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

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

      • values

        public static PeriodStyle[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PeriodStyle c : PeriodStyle.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PeriodStyle valueOf(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • matches

        protected boolean matches(java.lang.String value)
      • matcher

        protected final java.util.regex.Matcher matcher(java.lang.String value)
      • parse

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

        public abstract java.time.Period parse(java.lang.String value,
                                               java.time.temporal.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 java.lang.String print(java.time.Period value)
        Print the specified period.
        Parameters:
        value - the value to print
        Returns:
        the printed result
      • print

        public abstract java.lang.String print(java.time.Period value,
                                               java.time.temporal.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 java.time.Period detectAndParse(java.lang.String value)
        Detect the style then parse the value to return a period.
        Parameters:
        value - the value to parse
        Returns:
        the parsed period
        Throws:
        java.lang.IllegalArgumentException - if the value is not a known style or cannot be parsed
      • detectAndParse

        public 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.
        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:
        java.lang.IllegalArgumentException - if the value is not a known style or cannot be parsed
      • detect

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