org.springframework.boot.convert

Enum DurationStyle

    • 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(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:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • matches

        protected final boolean matches(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:
        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.
        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:
        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.
        Parameters:
        value - the source value
        Returns:
        the duration style
        Throws:
        IllegalStateException - if the value is not a known style

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.