Package org.keycloak.common.util
Class DurationConverter
java.lang.Object
org.keycloak.common.util.DurationConverter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisPositiveDuration(String value) Checks whether the given value represents a positive duration.static DurationparseDuration(String value) If thevaluestarts 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 withPTandDuration.parse(CharSequence)is called. If the value is a number followed byd, it is prefixed withPandDuration.parse(CharSequence)is called. Otherwise,Duration.parse(CharSequence)is called.
-
Field Details
-
DIGITS
-
-
Constructor Details
-
DurationConverter
public DurationConverter()
-
-
Method Details
-
parseDuration
If thevaluestarts 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 withPTandDuration.parse(CharSequence)is called. - If the value is a number followed by
d, it is prefixed withPandDuration.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
-
isPositiveDuration
Checks whether the given value represents a positive duration.- Parameters:
value- a string duration following the same format as inparseDuration(String)- Returns:
- true if the value represents a positive duration, false otherwise
-