Class DurationConverter

    • Field Detail

      • DIGITS

        public static final Pattern DIGITS
    • Constructor Detail

      • DurationConverter

        public DurationConverter()
    • Method Detail

      • convert

        public Duration convert​(String value)
        If the value starts with a number, then:
        • If the value is only a number, it is treated as a number of seconds.
        • If the value is a number followed by ms, it is treated as a number of milliseconds.
        • If the value is a number followed by h, m, or s, it is prefixed with PT and Duration.parse(CharSequence) is called.
        • If the value is a number followed by d, it is prefixed with P and Duration.parse(CharSequence) is called.
        Otherwise, Duration.parse(CharSequence) is called.
        Specified by:
        convert in interface org.eclipse.microprofile.config.spi.Converter<Duration>
        Parameters:
        value - a string duration
        Returns:
        the parsed Duration
        Throws:
        IllegalArgumentException - in case of parse failure
      • parseDuration

        public static Duration parseDuration​(String value)
        If the value starts with a number, then:
        • If the value is only a number, it is treated as a number of seconds.
        • If the value is a number followed by ms, it is treated as a number of milliseconds.
        • If the value is a number followed by h, m, or s, it is prefixed with PT and Duration.parse(CharSequence) is called.
        • If the value is a number followed by d, it is prefixed with P and Duration.parse(CharSequence) is called.
        Otherwise, Duration.parse(CharSequence) is called.
        Parameters:
        value - a string duration
        Returns:
        the parsed Duration
        Throws:
        IllegalArgumentException - in case of parse failure