Spring Web Flow

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
protected  java.text.DateFormat getDateFormat()
           
 java.util.Locale getLocale()
          The locale to use in formatting date values.
 java.lang.String getPattern()
          The pattern to use to format date values.
 void setLocale(java.util.Locale locale)
          Sets the locale to use in formatting date values.
 void setPattern(java.lang.String pattern)
          Sets the pattern to use to format date values.
 java.lang.Object toObject(java.lang.String string, java.lang.Class<?> targetClass)
           
 java.lang.String toString(java.lang.Object target)
           
 
Methods inherited from class org.springframework.binding.convert.converters.StringToObject
convertSourceToTargetClass, convertTargetToSourceClass, getSourceClass, getTargetClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringToDate

public StringToDate()
Method Detail

getPattern

public java.lang.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(java.lang.String pattern)
Sets the pattern to use to format date values.

Parameters:
pattern - the date formatting pattern

getLocale

public java.util.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(java.util.Locale locale)
Sets the locale to use in formatting date values.

Parameters:
locale - the locale

toObject

public java.lang.Object toObject(java.lang.String string,
                                 java.lang.Class<?> targetClass)
                          throws java.lang.Exception
Specified by:
toObject in class StringToObject
Throws:
java.lang.Exception

toString

public java.lang.String toString(java.lang.Object target)
                          throws java.lang.Exception
Specified by:
toString in class StringToObject
Throws:
java.lang.Exception

getDateFormat

protected java.text.DateFormat getDateFormat()

Spring Web Flow