public abstract class DateTypeHandlerSupport extends LocaleSupport implements ConfigurableTypeHandler, Cloneable
Date
,
DateFormat
,
SimpleDateFormat
Modifier and Type | Field and Description |
---|---|
protected boolean |
lenient |
protected String |
pattern |
protected TimeZone |
timeZone |
locale
FORMAT_SETTING
NIL
Constructor and Description |
---|
DateTypeHandlerSupport()
Constructs a new AbstractDateTypeHandler.
|
DateTypeHandlerSupport(String pattern)
Constructs a new AbstractDateTypeHandler.
|
Modifier and Type | Method and Description |
---|---|
protected DateFormat |
createDateFormat()
Creates the DateFormat to use to parse and format the field value.
|
protected DateFormat |
createDefaultDateFormat()
Creates a default date format when no pattern is set.
|
protected String |
formatDate(Date date)
Converts a
Date to text. |
String |
getPattern()
Returns the date pattern used by the SimpleDateFormat.
|
TimeZone |
getTimeZone()
Returns the configured
TimeZone or null if not set. |
String |
getTimeZoneId()
Returns the time zone used to interpret dates, or null if the default
time zone will be used.
|
boolean |
isLenient()
Returns whether the SimpleDateFormat is lenient.
|
DateTypeHandlerSupport |
newInstance(Properties properties)
Creates a customized instance of this type handler.
|
protected Date |
parseDate(String text)
Parses text into a
Date . |
void |
setLenient(boolean lenient)
Sets whether the SimpleDateFormat is lenient.
|
void |
setPattern(String pattern)
Sets the date pattern used by the SimpleDateFormat.
|
void |
setTimeZoneId(String name)
Sets the time zone for interpreting dates.
|
getLocale, setLocale
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
format, getType, parse
protected String pattern
protected boolean lenient
protected TimeZone timeZone
public DateTypeHandlerSupport()
public DateTypeHandlerSupport(String pattern)
pattern
- the SimpleDateFormat
patternprotected Date parseDate(String text) throws TypeConversionException
Date
.text
- the text to parseDate
TypeConversionException
protected String formatDate(Date date)
Date
to text.date
- the Date
to convertprotected DateFormat createDateFormat()
protected DateFormat createDefaultDateFormat()
public DateTypeHandlerSupport newInstance(Properties properties) throws IllegalArgumentException
ConfigurableTypeHandler
newInstance
in interface ConfigurableTypeHandler
properties
- the properties for customizing the instanceIllegalArgumentException
- if a property value is invalidpublic String getPattern()
public void setPattern(String pattern) throws IllegalArgumentException
pattern
- the date patternIllegalArgumentException
- if the date pattern is invalidpublic void setTimeZoneId(String name)
name
- the time zone IDTimeZone
public String getTimeZoneId()
TimeZone
public TimeZone getTimeZone()
TimeZone
or null if not set.TimeZone
public boolean isLenient()
public void setLenient(boolean lenient)
lenient
- true if lenient, false otherwise