public class DateConverter extends Object implements ValueConverter<Date>
Date
s using a DateFormat
object.Constructor and Description |
---|
DateConverter(DateFormat formatter)
Creates a converter that uses the given date formatter/parser.
|
Modifier and Type | Method and Description |
---|---|
Date |
convert(String value)
Converts the given string value into a Java type.
|
static DateConverter |
datePattern(String pattern)
Creates a converter that uses a
SimpleDateFormat with the given date/time pattern. |
String |
revert(Object value)
Reverts a value to a string representation.
|
String |
valuePattern()
Gives a string that describes the pattern of the values this converter expects, if any.
|
Class<Date> |
valueType()
Gives the class of the type of values this converter converts to.
|
public DateConverter(DateFormat formatter)
formatter
- the formatter/parser to useNullPointerException
- if formatter
is null
public static DateConverter datePattern(String pattern)
SimpleDateFormat
with the given date/time pattern. The date formatter
created is not lenient
.pattern
- expected date/time patternNullPointerException
- if pattern
is null
IllegalArgumentException
- if pattern
is invalidpublic Date convert(String value)
ValueConverter
convert
in interface ValueConverter<Date>
value
- the string to convertpublic String revert(Object value)
ValueConverter
Reverts a value to a string representation.
It is not strictly required that revert(convert(v)).equals(v)
,
but it is recommended.
revert
in interface ValueConverter<Date>
value
- a valuepublic Class<Date> valueType()
ValueConverter
valueType
in interface ValueConverter<Date>
public String valuePattern()
ValueConverter
date format string
.valuePattern
in interface ValueConverter<Date>
null
if there's nothing interesting here© Copyright 2004-2016 Paul R. Holser, Jr. All rights reserved. Licensed under The MIT License.