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

public abstract class JavaTimeConverter<T extends TemporalAccessor> extends BaseConverter<T>
Base class for all java.time converters.
  • Constructor Details

    • JavaTimeConverter

      protected JavaTimeConverter(String optionName, Class<T> toClass)
      Inheritor constructors should have only 1 parameter - optionName.
      Parameters:
      optionName - name of the option
      toClass - type to parse into
  • Method Details

    • convert

      public final T convert(String value)
      Returns:
      an object of type T created from the parameter value.
    • supportedFormats

      protected abstract Set<DateTimeFormatter> supportedFormats()
      Supported formats for this type, e.g. HH:mm:ss
      Returns:
      a set of supported formats
    • parse

      protected abstract T parse(String value, DateTimeFormatter formatter)
      Parse the value using the specified formatter.
      Parameters:
      value - value to parse
      formatter - formatter specifying supported format
      Returns:
      parsed value