Class DateTypeHandler

  • All Implemented Interfaces:
    java.lang.Cloneable, ConfigurableTypeHandler, TypeHandler
    Direct Known Subclasses:
    AbstractXmlDateTypeHandler

    public class DateTypeHandler
    extends DateTypeHandlerSupport
    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.
    Since:
    1.0
    See Also:
    Date, DateFormat, SimpleDateFormat
    • Constructor Detail

      • DateTypeHandler

        public DateTypeHandler()
        Constructs a new DateTypeHandler.
      • DateTypeHandler

        public DateTypeHandler​(java.lang.String pattern)
        Constructs a new DateTypeHandler.
        Parameters:
        pattern - the SimpleDateFormat pattern
    • Method Detail

      • parse

        public java.util.Date 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, or TypeHandler.NIL for XML formatted streams
      • 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