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 Details

    • datePattern

      protected String datePattern
    • timeZone

      protected TimeZone timeZone
    • dateFormat

      protected org.apache.commons.lang3.time.FastDateFormat dateFormat
  • Constructor Details

    • StringToDateConverter

      public StringToDateConverter()
  • Method Details

    • setDatePattern

      public void setDatePattern(String datePattern)
    • setTimeZone

      public void setTimeZone(String timeZone)
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.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 interface Converter<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 interface Converter<String,Date>
    • convert

      public Date convert(String source)
      Description copied from interface: Converter
      Converts the source object from S type to T type.
      Specified by:
      convert in interface Converter<String,Date>
      Parameters:
      source - the object to convert
      Returns:
      the converted object