org.springframework.binding.format.support
Class DateFormatter

java.lang.Object
  extended by org.springframework.binding.format.support.AbstractFormatter
      extended by org.springframework.binding.format.support.DateFormatter
All Implemented Interfaces:
Formatter

public class DateFormatter
extends AbstractFormatter

Formatter that formats date objects.

Author:
Keith Donald

Constructor Summary
DateFormatter(java.text.DateFormat dateFormat)
          Constructs a date formatter that will delegate to the specified date format.
DateFormatter(java.text.DateFormat dateFormat, boolean allowEmpty)
          Constructs a date formatter that will delegate to the specified date format.
 
Method Summary
protected  java.lang.String doFormatValue(java.lang.Object date)
          Template method subclasses should override to encapsulate formatting logic.
protected  java.lang.Object doParseValue(java.lang.String formattedString, java.lang.Class targetClass)
          Template method subclasses should override to encapsulate parsing logic.
 java.util.Date parseDate(java.lang.String formattedString)
          Convenience method to parse a date.
 
Methods inherited from class org.springframework.binding.format.support.AbstractFormatter
formatValue, getEmptyFormattedValue, getEmptyValue, getExpectedFormat, isAllowEmpty, isEmpty, parseValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatter

public DateFormatter(java.text.DateFormat dateFormat)
Constructs a date formatter that will delegate to the specified date format.

Parameters:
dateFormat - the date format to use

DateFormatter

public DateFormatter(java.text.DateFormat dateFormat,
                     boolean allowEmpty)
Constructs a date formatter that will delegate to the specified date format.

Parameters:
dateFormat - the date format to use
allowEmpty - should this formatter allow empty input arguments?
Method Detail

doFormatValue

protected java.lang.String doFormatValue(java.lang.Object date)
Description copied from class: AbstractFormatter
Template method subclasses should override to encapsulate formatting logic.

Specified by:
doFormatValue in class AbstractFormatter
Parameters:
date - the value to format
Returns:
the formatted string representation

doParseValue

protected java.lang.Object doParseValue(java.lang.String formattedString,
                                        java.lang.Class targetClass)
                                 throws java.text.ParseException
Description copied from class: AbstractFormatter
Template method subclasses should override to encapsulate parsing logic.

Specified by:
doParseValue in class AbstractFormatter
Parameters:
formattedString - the formatted string to parse
Returns:
the parsed value
Throws:
java.text.ParseException - when parse exceptions occur

parseDate

public java.util.Date parseDate(java.lang.String formattedString)
                         throws InvalidFormatException
Convenience method to parse a date.

Throws:
InvalidFormatException


Copyright © 2009 Spring Framework. All Rights Reserved.