Top Description Fields Constructors Methods
jdk.internal.joptsimple.util

public Class DateConverter

extends Object
implements ValueConverter<Date>
Class Inheritance
All Implemented Interfaces
jdk.internal.joptsimple.ValueConverter
Imports
java.text.DateFormat, .ParsePosition, .SimpleDateFormat, java.util.Date, .Locale, jdk.internal.joptsimple.ValueConversionException, .ValueConverter, jdk.internal.joptsimple.internal.Messages

Converts values to Dates using a DateFormat object.
Author
Paul Holser

Field Summary

Modifier and TypeField and Description
private final DateFormat

Constructor Summary

AccessConstructor and Description
public
DateConverter(DateFormat
the formatter/parser to use
formatter
)

Creates a converter that uses the given date formatter/parser.

Method Summary

Modifier and TypeMethod and Description
public Date
convert(String
the string to convert
value
)

Implements jdk.internal.joptsimple.ValueConverter.convert.

Converts the given string value into a Java type.
public static DateConverter

Returns:

the new converter
datePattern
(String
expected date/time pattern
pattern
)

Creates a converter that uses a SimpleDateFormat with the given date/time pattern.

private String
message(String value)

public String
valuePattern()

Implements jdk.internal.joptsimple.ValueConverter.valuePattern.

Gives a string that describes the pattern of the values this converter expects, if any.
public Class<Date>
valueType()

Implements jdk.internal.joptsimple.ValueConverter.valueType.

Gives the class of the type of values this converter converts to.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

formatterback to summary
private final DateFormat formatter

Constructor Detail

DateConverterback to summary
public DateConverter(DateFormat formatter)

Creates a converter that uses the given date formatter/parser.

Parameters
formatter:DateFormat

the formatter/parser to use

Exceptions
NullPointerException:
if formatter is null

Method Detail

convertback to summary
public Date convert(String value)

Implements jdk.internal.joptsimple.ValueConverter.convert.

Doc from jdk.internal.joptsimple.ValueConverter.convert.

Converts the given string value into a Java type.

Parameters
value:String

the string to convert

Returns:Date

the converted value

datePatternback to summary
public static DateConverter datePattern(String pattern)

Creates a converter that uses a SimpleDateFormat with the given date/time pattern. The date formatter created is not lenient.

Parameters
pattern:String

expected date/time pattern

Returns:DateConverter

the new converter

Exceptions
NullPointerException:
if pattern is null
IllegalArgumentException:
if pattern is invalid
messageback to summary
private String message(String value)
valuePatternback to summary
public String valuePattern()

Implements jdk.internal.joptsimple.ValueConverter.valuePattern.

Doc from jdk.internal.joptsimple.ValueConverter.valuePattern.

Gives a string that describes the pattern of the values this converter expects, if any. For example, a date converter can respond with a date format string.

Returns:String

a value pattern, or null if there's nothing interesting here

valueTypeback to summary
public Class<Date> valueType()

Implements jdk.internal.joptsimple.ValueConverter.valueType.

Doc from jdk.internal.joptsimple.ValueConverter.valueType.

Gives the class of the type of values this converter converts to.

Returns:Class<Date>

the target class for conversion