Class DateTimeConverter

  • All Implemented Interfaces:
    IConverter
    Direct Known Subclasses:
    DateConverter, TimeConverter

    public class DateTimeConverter
    extends AbstractConverter
    This converter is able to do conversion between Date and its java.sql subtypes, String and Long. Long is treated as UTC. It can convert a Calendar as source value, but not as destination value.

    By default this converter uses the jvm date time formats, if pattern is not specified. Use TimeConverter or DateConverter to default to jvm date or time formats.

    This class accepts patterns specified in SimpleDateFormat or the string "ISO8601" for ISO-8601 format pattern.

    Since:
    4.0.4
    Version:
    $Revision: 24221 $ $Date: 2020-11-09 20:23:09 -0300 (Mon, 09 Nov 2020) $
    See Also:
    Date
    • Constructor Detail

      • DateTimeConverter

        public DateTimeConverter()
    • Method Detail

      • createDateFormat

        protected DateFormat createDateFormat​(Locale locale,
                                              String pattern)
        Creates the DateFormat for the given locale and pattern.
        Parameters:
        locale - the locale.
        pattern - the pattern.
        Returns:
        the DateFormat created.
        Since:
        4.0.4
        See Also:
        DateFormat
      • doConversion

        protected <T> T doConversion​(Class<T> type,
                                     Object value,
                                     Locale locale,
                                     String pattern)
                              throws UnsupportedConversionTypeException
        Description copied from class: AbstractConverter
        Converts the specified input object into an output object of the specified type.
        Specified by:
        doConversion in class AbstractConverter
        Type Parameters:
        T - generics support for the data type specified.
        Parameters:
        type - data type to which the value should be converted.
        value - the input value to be converted.
        locale - locale to be used during conversion, if necessary.
        pattern - converter specific conversion pattern, to be used during conversion, if necessary.
        Throws:
        UnsupportedConversionTypeException - if this converter does not supports converting to the specified type.