Package org.beanio.types
Class CalendarTypeHandler
- java.lang.Object
-
- org.beanio.types.LocaleSupport
-
- org.beanio.types.DateTypeHandlerSupport
-
- org.beanio.types.CalendarTypeHandler
-
- All Implemented Interfaces:
java.lang.Cloneable
,ConfigurableTypeHandler
,TypeHandler
- Direct Known Subclasses:
AbstractXmlCalendarTypeHandler
public class CalendarTypeHandler extends DateTypeHandlerSupport
This type handler uses aSimpleDateFormat
to parse and formatjava.util.Calendar
objects. If no pattern is set,DateFormat.getInstance()
is used to create a default date format. By default,lenient
is false.- Since:
- 2.1.0
- See Also:
Date
,DateFormat
,SimpleDateFormat
-
-
Field Summary
-
Fields inherited from class org.beanio.types.DateTypeHandlerSupport
lenient, pattern, timeZone
-
Fields inherited from class org.beanio.types.LocaleSupport
locale
-
Fields inherited from interface org.beanio.types.ConfigurableTypeHandler
FORMAT_SETTING
-
Fields inherited from interface org.beanio.types.TypeHandler
NIL
-
-
Constructor Summary
Constructors Constructor Description CalendarTypeHandler()
Constructs a new CalendarTypeHandler.CalendarTypeHandler(java.lang.String pattern)
Constructs a new CalendarTypeHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
format(java.lang.Object value)
Formats a Java object into field text.protected java.lang.String
formatCalendar(java.util.Calendar calendar)
java.lang.Class<?>
getType()
Returns the class type supported by this handler.java.util.Calendar
parse(java.lang.String text)
Parses field text into a Java object.-
Methods inherited from class org.beanio.types.DateTypeHandlerSupport
createDateFormat, createDefaultDateFormat, formatDate, getPattern, getTimeZone, getTimeZoneId, isLenient, newInstance, parseDate, setLenient, setPattern, setTimeZoneId
-
Methods inherited from class org.beanio.types.LocaleSupport
getLocale, setLocale
-
-
-
-
Method Detail
-
parse
public java.util.Calendar parse(java.lang.String text) throws TypeConversionException
Description copied from interface:TypeHandler
Parses field text into a Java object.- Parameters:
text
- the field text to parse, which may be null if the field was not passed in the record- Returns:
- the parsed Java object
- Throws:
TypeConversionException
- if the text cannot be parsed
-
format
public java.lang.String format(java.lang.Object value)
Description copied from interface:TypeHandler
Formats a Java object into field text.- Parameters:
value
- the Java object to format, which may be null- Returns:
- the formatted field text, or
null
to indicate the value is not present, orTypeHandler.NIL
for XML formatted streams
-
formatCalendar
protected java.lang.String formatCalendar(java.util.Calendar calendar)
-
getType
public java.lang.Class<?> getType()
Description copied from interface:TypeHandler
Returns the class type supported by this handler. Primitive types should not be returned by this method- use the object equivalent instead.- Returns:
- the class type supported by this handler
-
-