org.springframework.boot.convert

Enum DurationStyle

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


    public enum DurationStyle
    extends java.lang.Enum<DurationStyle>
    Duration format styles.
    Since:
    2.0.0
    • Enum Constant Summary

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

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      static DurationStyle detect(java.lang.String value)
      Detect the style from the given source value.
      static java.time.Duration detectAndParse(java.lang.String value)
      Detect the style then parse the value to return a duration.
      static java.time.Duration detectAndParse(java.lang.String value, java.time.temporal.ChronoUnit unit)
      Detect the style then parse the value to return a duration.
      protected java.util.regex.Matcher matcher(java.lang.String value) 
      protected boolean matches(java.lang.String value) 
      java.time.Duration parse(java.lang.String value)
      Parse the given value to a duration.
      abstract java.time.Duration parse(java.lang.String value, java.time.temporal.ChronoUnit unit)
      Parse the given value to a duration.
      java.lang.String print(java.time.Duration value)
      Print the specified duration.
      abstract java.lang.String print(java.time.Duration value, java.time.temporal.ChronoUnit unit)
      Print the specified duration using the given unit.
      static DurationStyle valueOf(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static DurationStyle[] 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 DurationStyle SIMPLE
        Simple formatting, for example '1s'.
      • ISO8601

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

      • values

        public static DurationStyle[] 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 (DurationStyle c : DurationStyle.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static DurationStyle 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 final boolean matches(java.lang.String value)
      • matcher

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

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

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

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

        public static java.time.Duration detectAndParse(java.lang.String value,
                                                        java.time.temporal.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:
        java.lang.IllegalStateException - if the value is not a known style or cannot be parsed
      • detect

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