org.codehaus.waffle.bind.converters
Class DateValueConverter
java.lang.Object
org.codehaus.waffle.bind.converters.AbstractValueConverter
org.codehaus.waffle.bind.converters.DateValueConverter
- All Implemented Interfaces:
- ValueConverter
public class DateValueConverter
- extends AbstractValueConverter
ValueConverter that converts Date values. The date format is configurable via the message resources
bundle. A null or empty value (once trimmed) will be returned as null (behaviour which
can be overridden via the convertMissingValue() method), while an invalid value will cause a BindException to
be thrown. The message keys and default values used are:
The patterns are also optionally injectable via Properties in the constructor and take precedence over
the ones configured in the messages resources.
- Author:
- Michael Ward, Mauro Talevi
|
Method Summary |
boolean |
accept(java.lang.Class<?> type)
Determines if converter is compatible with the given type |
void |
changePatterns(java.util.Properties patterns)
|
|
convertValue(java.lang.String propertyName,
java.lang.String value,
java.lang.Class<T> toType)
Converts a String value to an Object of a given type |
java.util.Properties |
getPatterns()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BIND_ERROR_DATE_KEY
public static final java.lang.String BIND_ERROR_DATE_KEY
- See Also:
- Constant Field Values
BIND_ERROR_DATE_MISSING_KEY
public static final java.lang.String BIND_ERROR_DATE_MISSING_KEY
- See Also:
- Constant Field Values
DATE_FORMAT_KEY
public static final java.lang.String DATE_FORMAT_KEY
- See Also:
- Constant Field Values
DAY_FORMAT_KEY
public static final java.lang.String DAY_FORMAT_KEY
- See Also:
- Constant Field Values
DAY_NAME_KEY
public static final java.lang.String DAY_NAME_KEY
- See Also:
- Constant Field Values
TIME_FORMAT_KEY
public static final java.lang.String TIME_FORMAT_KEY
- See Also:
- Constant Field Values
TIME_NAME_KEY
public static final java.lang.String TIME_NAME_KEY
- See Also:
- Constant Field Values
DEFAULT_DAY_FORMAT
public static final java.lang.String DEFAULT_DAY_FORMAT
- See Also:
- Constant Field Values
DEFAULT_DAY_NAME
public static final java.lang.String DEFAULT_DAY_NAME
- See Also:
- Constant Field Values
DEFAULT_TIME_FORMAT
public static final java.lang.String DEFAULT_TIME_FORMAT
- See Also:
- Constant Field Values
DEFAULT_TIME_NAME
public static final java.lang.String DEFAULT_TIME_NAME
- See Also:
- Constant Field Values
DEFAULT_DATE_FORMAT
public static final java.lang.String DEFAULT_DATE_FORMAT
- See Also:
- Constant Field Values
DEFAULT_DATE_MESSAGE
public static final java.lang.String DEFAULT_DATE_MESSAGE
- See Also:
- Constant Field Values
DEFAULT_DATE_MISSING_MESSAGE
public static final java.lang.String DEFAULT_DATE_MISSING_MESSAGE
- See Also:
- Constant Field Values
DateValueConverter
public DateValueConverter(MessageResources messageResources)
DateValueConverter
public DateValueConverter(MessageResources messageResources,
java.util.Properties patterns)
accept
public boolean accept(java.lang.Class<?> type)
- Description copied from interface:
ValueConverter
- Determines if converter is compatible with the given type
- Parameters:
type - the type of the field a value is to be bound to
- Returns:
- A boolean
true is type is compatible
convertValue
public <T> T convertValue(java.lang.String propertyName,
java.lang.String value,
java.lang.Class<T> toType)
- Description copied from interface:
ValueConverter
- Converts a String value to an Object of a given type
- Parameters:
propertyName - the associated property name, which can be null, also needed to present
customized error messages.value - the String valuetoType - the Object type
- Returns:
- The converted Object
getPatterns
public java.util.Properties getPatterns()
changePatterns
public void changePatterns(java.util.Properties patterns)
Copyright © 2008. All Rights Reserved.