Package lumis.util.converter
Class DateTimeConverter
- java.lang.Object
-
- lumis.util.converter.AbstractConverter
-
- lumis.util.converter.DateTimeConverter
-
- All Implemented Interfaces:
IConverter
- Direct Known Subclasses:
DateConverter
,TimeConverter
public class DateTimeConverter extends AbstractConverter
This converter is able to do conversion betweenDate
and its java.sql subtypes, String and Long. Long is treated as UTC. It can convert aCalendar
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
orDateConverter
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DateTimeConverter.ISO8601DateTimeFormat
Implementation of DateFormat for ISO-8601 parsing and formatting.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PATTERN_ISO_8601
-
Constructor Summary
Constructors Constructor Description DateTimeConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.text.DateFormat
createDateFormat(java.util.Locale locale, java.lang.String pattern)
Creates the DateFormat for the given locale and pattern.protected <T> T
doConversion(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
Converts the specified input object into an output object of the specified type.-
Methods inherited from class lumis.util.converter.AbstractConverter
convert, convert, convert, doesNullValueReturnNull, doesValueInstanceOfTypeReturnValue, getDefaultLocale, getDefaultPattern, setDefaultLocale, setDefaultPattern, setFallbackToRegisteredConverters, shouldFallbackToRegisteredConverters
-
-
-
-
Field Detail
-
PATTERN_ISO_8601
public static final java.lang.String PATTERN_ISO_8601
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDateFormat
protected java.text.DateFormat createDateFormat(java.util.Locale locale, java.lang.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(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.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 classAbstractConverter
- 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.
-
-