|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.types.DateTypeHandler
public class DateTypeHandler
This type handler uses a SimpleDateFormat class to parse and format java.util.Date objects. If no pattern is set, DateFormat.getInstance() is used to create a default date format. By default, lenient is false.
Date
,
DateFormat
,
SimpleDateFormat
Field Summary |
---|
Fields inherited from interface org.beanio.types.ConfigurableTypeHandler |
---|
FORMAT_SETTING |
Fields inherited from interface org.beanio.types.TypeHandler |
---|
NIL |
Constructor Summary | |
---|---|
DateTypeHandler()
Constructs a new DateTypeHandler. |
|
DateTypeHandler(String pattern)
Constructs a new DateTypeHandler. |
Method Summary | |
---|---|
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. |
String |
format(Object value)
Formats a Java object into field text. |
String |
getPattern()
Returns the date pattern used by the SimpleDateFormat. |
Class<?> |
getType()
Returns the class type supported by this handler. |
boolean |
isLenient()
Returns whether the SimpleDateFormat is lenient. |
DateTypeHandler |
newInstance(Properties properties)
Creates a customized instance of this type handler. |
Date |
parse(String text)
Parses field text into a Java object. |
void |
setLenient(boolean lenient)
Sets whether the SimpleDateFormat is lenient. |
void |
setPattern(String pattern)
Sets the date pattern used by the SimpleDateFormat. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DateTypeHandler()
public DateTypeHandler(String pattern)
pattern
- the SimpleDateFormat patternMethod Detail |
---|
public Date parse(String text) throws TypeConversionException
TypeHandler
parse
in interface TypeHandler
text
- the field text to parse, which may be null if the field was not passed in the record
TypeConversionException
- if the text cannot be parsedpublic String format(Object value)
TypeHandler
format
in interface TypeHandler
value
- the Java object to format, which may be null
TypeHandler.NIL
for XML formatted streamspublic DateTypeHandler newInstance(Properties properties) throws IllegalArgumentException
ConfigurableTypeHandler
newInstance
in interface ConfigurableTypeHandler
properties
- the properties for customizing the instance
IllegalArgumentException
- if a property value is invalidprotected DateFormat createDateFormat()
protected DateFormat createDefaultDateFormat()
public Class<?> getType()
TypeHandler
getType
in interface TypeHandler
public String getPattern()
public void setPattern(String pattern) throws IllegalArgumentException
pattern
- the date pattern
IllegalArgumentException
- if the date pattern is invalidpublic boolean isLenient()
public void setLenient(boolean lenient)
lenient
- true if lenient, false otherwise
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |