Package snaq.util.jclap
Class LocalDateOption
public class LocalDateOption extends Option<LocalDate>
Option implementation for specifying date values.
- Author:
- Giles Winstanley
-
Field Summary
-
Constructor Summary
Constructors Constructor Description LocalDateOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Creates a newLocalDateOptioninstance.LocalDateOption(String shortName, String longName, String description, int minCount, int maxCount)Creates a newLocalDateOptioninstance. -
Method Summary
Modifier and Type Method Description DateTimeFormattergetDateFormat(Locale locale)Class<LocalDate>getType()Returns the class type of value this option can take.protected LocalDateparseValue(String arg, Locale locale)Parses the argument string for an option value, optionally using the specified locale for reference (e.g.voidsetDateFormat(DateTimeFormatter dtf)Sets theDateTimeFormatterinstance forLocalDateparsing/display.Methods inherited from class snaq.util.jclap.Option
addValue, equals, getDescription, getLongName, getMaxCount, getMinCount, getShortName, getValues, hashCode, isAllowMany, isHidden, isMandatory, requiresValue, setHidden, setMinMaxCounts, toString
-
Constructor Details
-
LocalDateOption
public LocalDateOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Creates a newLocalDateOptioninstance.- 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 specifiedallowMany- 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 newLocalDateOptioninstance.- 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 optionmaxCount- maximum number of occurrences required for this option
-
-
Method Details
-
getType
Returns the class type of value this option can take. -
parseValue
Parses the argument string for an option value, optionally using the specified locale for reference (e.g. for date parsing).- Specified by:
parseValuein classOption<LocalDate>- Parameters:
arg- string argument from which a value is to be parsedlocale- locale as specified when initializing theCLAParserinstance- Returns:
- Value of the parsed argument string
- Throws:
OptionException- if a problem occurs while parsing the argument string
-
setDateFormat
Sets theDateTimeFormatterinstance forLocalDateparsing/display.- Parameters:
dtf-DateTimeFormatterinstance to use
-
getDateFormat
- Parameters:
locale- locale forDateFormatterinstance- Returns:
- The
DateFormatterinstance used to parse dates.
-