java.lang.Object
org.springframework.binding.convert.converters.StringToObject
org.springframework.binding.convert.converters.StringToDate
All Implemented Interfaces:
Converter, TwoWayConverter

public class StringToDate extends StringToObject
A formatter for Date types. Allows the configuration of an explicit date pattern and locale.
Author:
Keith Donald
See Also:
  • Constructor Details

    • StringToDate

      public StringToDate()
  • Method Details

    • getPattern

      public String getPattern()
      The pattern to use to format date values. If not specified, the default pattern 'yyyy-MM-dd' is used.
      Returns:
      the date formatting pattern
    • setPattern

      public void setPattern(String pattern)
      Sets the pattern to use to format date values.
      Parameters:
      pattern - the date formatting pattern
    • getLocale

      public Locale getLocale()
      The locale to use in formatting date values. If not specified, the locale of the current thread is used.
      Returns:
      the locale
      See Also:
      • LocaleContextHolder.getLocale()
    • setLocale

      public void setLocale(Locale locale)
      Sets the locale to use in formatting date values.
      Parameters:
      locale - the locale
    • toObject

      public Object toObject(String string, Class<?> targetClass)
      Specified by:
      toObject in class StringToObject
    • toString

      public String toString(Object target)
      Specified by:
      toString in class StringToObject
    • getDateFormat

      protected DateFormat getDateFormat()