org.springframework.binding.convert.converters
Class StringToDate

java.lang.Object
  extended by org.springframework.binding.convert.converters.StringToObject
      extended by 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:
SimpleDateFormat

Constructor Summary
StringToDate()
           
 
Method Summary
 Locale getLocale()
          The locale to use in formatting date values.
 String getPattern()
          The pattern to use to format date values.
 void setLocale(Locale locale)
          Sets the locale to use in formatting date values.
 void setPattern(String pattern)
          Sets the pattern to use to format date values.
 Object toObject(String string, Class targetClass)
           
 String toString(Object target)
           
 
Methods inherited from class org.springframework.binding.convert.converters.StringToObject
convertSourceToTargetClass, convertTargetToSourceClass, getSourceClass, getTargetClass
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringToDate

public StringToDate()
Method Detail

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)
                throws Exception
Throws:
Exception

toString

public String toString(Object target)
                throws Exception
Throws:
Exception