Package com.beust.jcommander.converters
Class JavaTimeConverter<T extends TemporalAccessor>
java.lang.Object
com.beust.jcommander.converters.BaseConverter<T>
com.beust.jcommander.converters.JavaTimeConverter<T>
- Type Parameters:
T
- concrete type to parse into
- All Implemented Interfaces:
IStringConverter<T>
- Direct Known Subclasses:
InstantConverter
,LocalDateConverter
,LocalDateTimeConverter
,LocalTimeConverter
,OffsetDateTimeConverter
,OffsetTimeConverter
,ZonedDateTimeConverter
Base class for all
java.time
converters.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JavaTimeConverter
(String optionName, Class<T> toClass) Inheritor constructors should have only 1 parameter - optionName. -
Method Summary
Modifier and TypeMethodDescriptionfinal T
protected abstract T
parse
(String value, DateTimeFormatter formatter) Parse the value using the specified formatter.protected abstract Set
<DateTimeFormatter> Supported formats for this type, e.g.Methods inherited from class com.beust.jcommander.converters.BaseConverter
getErrorString, getOptionName
-
Constructor Details
-
JavaTimeConverter
Inheritor constructors should have only 1 parameter - optionName.- Parameters:
optionName
- name of the optiontoClass
- type to parse into
-
-
Method Details
-
convert
- Returns:
- an object of type T created from the parameter value.
-
supportedFormats
Supported formats for this type, e.g.HH:mm:ss
- Returns:
- a set of supported formats
-
parse
Parse the value using the specified formatter.- Parameters:
value
- value to parseformatter
- formatter specifying supported format- Returns:
- parsed value
-