Class StringToDateConverter
- java.lang.Object
-
- org.craftercms.commons.converters.impl.StringToDateConverter
-
- All Implemented Interfaces:
Converter<String,Date>
,org.springframework.beans.factory.InitializingBean
public class StringToDateConverter extends Object implements Converter<String,Date>, org.springframework.beans.factory.InitializingBean
Converts String to Date, with a custom pattern and time zone.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.lang3.time.FastDateFormat
dateFormat
protected String
datePattern
protected TimeZone
timeZone
-
Constructor Summary
Constructors Constructor Description StringToDateConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Date
convert(String source)
Converts the source object from S type to T type.Class<?>
getSourceClass()
Returns the class of the objects this converter converts from.Class<?>
getTargetClass()
Returns the class of the objects this converter converts to.void
setDatePattern(String datePattern)
void
setTimeZone(String timeZone)
-
-
-
Method Detail
-
setDatePattern
public void setDatePattern(String datePattern)
-
setTimeZone
public void setTimeZone(String timeZone)
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
getSourceClass
public Class<?> getSourceClass()
Description copied from interface:Converter
Returns the class of the objects this converter converts from.- Specified by:
getSourceClass
in interfaceConverter<String,Date>
-
getTargetClass
public Class<?> getTargetClass()
Description copied from interface:Converter
Returns the class of the objects this converter converts to.- Specified by:
getTargetClass
in interfaceConverter<String,Date>
-
-