Class LocalDateOption


  • public class LocalDateOption
    extends Option<LocalDate>
    Option implementation for specifying date values.
    Author:
    Giles Winstanley
    • Constructor Detail

      • LocalDateOption

        public LocalDateOption​(String shortName,
                               String longName,
                               String description,
                               boolean mandatory,
                               boolean allowMany)
        Creates a new LocalDateOption instance.
        Parameters:
        shortName - short name of the option (e.g. -t)
        longName - long name of the option (e.g. --type)
        description - helpful description of the option (printed for usage message)
        mandatory - whether this option must be specified
        allowMany - whether this option can take more than one value (i.e. be specified more than once)
      • LocalDateOption

        public LocalDateOption​(String shortName,
                               String longName,
                               String description,
                               int minCount,
                               int maxCount)
        Creates a new LocalDateOption instance.
        Parameters:
        shortName - short name of the option (e.g. -t)
        longName - long name of the option (e.g. --type)
        description - helpful description of the option (printed for usage message)
        minCount - minimum number of occurrences required for this option
        maxCount - maximum number of occurrences required for this option
    • Method Detail

      • parseValue

        protected LocalDate parseValue​(String arg,
                                       Locale locale)
                                throws OptionException
        Parses the argument string for an option value, optionally using the specified locale for reference (e.g. for date parsing).
        Specified by:
        parseValue in class Option<LocalDate>
        Parameters:
        arg - string argument from which a value is to be parsed
        locale - locale as specified when initializing the CLAParser instance
        Returns:
        Value of the parsed argument string
        Throws:
        OptionException - if a problem occurs while parsing the argument string
      • setDateFormat

        public void setDateFormat​(DateTimeFormatter dtf)
        Sets the DateTimeFormatter instance for LocalDate parsing/display.
        Parameters:
        dtf - DateTimeFormatter instance to use
      • getDateFormat

        public DateTimeFormatter getDateFormat​(Locale locale)
        Parameters:
        locale - locale for DateFormatter instance
        Returns:
        The DateFormatter instance used to parse dates.