Package io.quarkus.runtime.configuration
Class DurationConverter
- java.lang.Object
-
- io.quarkus.runtime.configuration.DurationConverter
-
- All Implemented Interfaces:
Serializable
,org.eclipse.microprofile.config.spi.Converter<Duration>
@Priority(200) public class DurationConverter extends Object implements org.eclipse.microprofile.config.spi.Converter<Duration>, Serializable
A converter for aDuration
interface.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DurationConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Duration
convert(String value)
If thevalue
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 byms
, it is treated as a number of milliseconds. If the value is a number followed byh
,m
, ors
, it is prefixed withPT
andDuration.parse(CharSequence)
is called. If the value is a number followed byd
, it is prefixed withP
andDuration.parse(CharSequence)
is called. Otherwise,Duration.parse(CharSequence)
is called.static Duration
parseDuration(String value)
If thevalue
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 byms
, it is treated as a number of milliseconds. If the value is a number followed byh
,m
, ors
, it is prefixed withPT
andDuration.parse(CharSequence)
is called. If the value is a number followed byd
, it is prefixed withP
andDuration.parse(CharSequence)
is called. Otherwise,Duration.parse(CharSequence)
is called.
-
-
-
Field Detail
-
DIGITS
public static final Pattern DIGITS
-
-
Method Detail
-
convert
public Duration convert(String value)
If thevalue
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
, ors
, it is prefixed withPT
andDuration.parse(CharSequence)
is called. - If the value is a number followed by
d
, it is prefixed withP
andDuration.parse(CharSequence)
is called.
Duration.parse(CharSequence)
is called.- Specified by:
convert
in interfaceorg.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 thevalue
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
, ors
, it is prefixed withPT
andDuration.parse(CharSequence)
is called. - If the value is a number followed by
d
, it is prefixed withP
andDuration.parse(CharSequence)
is called.
Duration.parse(CharSequence)
is called.- Parameters:
value
- a string duration- Returns:
- the parsed
Duration
- Throws:
IllegalArgumentException
- in case of parse failure
-
-