Package joptsimple.util
Class DateConverter
java.lang.Object
joptsimple.util.DateConverter
- All Implemented Interfaces:
ValueConverter<Date>
Converts values to
Date
s using a DateFormat
object.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDateConverter
(DateFormat formatter) Creates a converter that uses the given date formatter/parser. -
Method Summary
Modifier and TypeMethodDescriptionConverts the given string value into a Java type.static DateConverter
datePattern
(String pattern) Creates a converter that uses aSimpleDateFormat
with the given date/time pattern.private String
Gives a string that describes the pattern of the values this converter expects, if any.Gives the class of the type of values this converter converts to.
-
Field Details
-
formatter
-
-
Constructor Details
-
DateConverter
Creates a converter that uses the given date formatter/parser.- Parameters:
formatter
- the formatter/parser to use- Throws:
NullPointerException
- ifformatter
isnull
-
-
Method Details
-
datePattern
Creates a converter that uses aSimpleDateFormat
with the given date/time pattern. The date formatter created is notlenient
.- Parameters:
pattern
- expected date/time pattern- Returns:
- the new converter
- Throws:
NullPointerException
- ifpattern
isnull
IllegalArgumentException
- ifpattern
is invalid
-
convert
Description copied from interface:ValueConverter
Converts the given string value into a Java type.- Specified by:
convert
in interfaceValueConverter<Date>
- Parameters:
value
- the string to convert- Returns:
- the converted value
-
valueType
Description copied from interface:ValueConverter
Gives the class of the type of values this converter converts to.- Specified by:
valueType
in interfaceValueConverter<Date>
- Returns:
- the target class for conversion
-
valuePattern
Description copied from interface:ValueConverter
Gives a string that describes the pattern of the values this converter expects, if any. For example, a date converter can respond with adate format string
.- Specified by:
valuePattern
in interfaceValueConverter<Date>
- Returns:
- a value pattern, or
null
if there's nothing interesting here
-
message
-