public class DefaultObjectStringConverter extends ConvertUtilsObjectStringConverter
Default string <-> object conversion strategy.
This delegates to ConvertUtils except when the type
is assignable from java.util.Date
but not from java.sql.Date
.
In this case, the format used is (in SimpleDateFormat terms)
EEE MMM dd HH:mm:ss zzz yyyy
.
This is the same as the output of the toString method on java.util.Date.
This should preserve the existing symantic behaviour whilst allowing round tripping of dates (given the default settings).
FLAVOUR_OPTION_NAME
Constructor and Description |
---|
DefaultObjectStringConverter() |
Modifier and Type | Method and Description |
---|---|
protected void |
handleException(Exception e)
Allow subclasses to use a different exception handling strategy.
|
String |
objectToString(Object object,
Class type,
String flavour,
Context context)
Converts an object to a string representation using ConvertUtils.
|
Object |
stringToObject(String value,
Class type,
String flavour,
Context context)
Converts an object to a string representation using ConvertUtils.
|
objectToString, stringToObject
public String objectToString(Object object, Class type, String flavour, Context context)
EEE MMM dd HH:mm:ss zzz yyyy
will be used.
(This is the same as java.util.Date toString would return.)objectToString
in class ConvertUtilsObjectStringConverter
object
- the object to be converted, possibly nulltype
- the property class of the object, not nullflavour
- a string allow symantic differences in formatting
to be communicated (ignored)context
- convert against this context not nullpublic Object stringToObject(String value, Class type, String flavour, Context context)
stringToObject
in class ConvertUtilsObjectStringConverter
value
- the String to be converted, not nulltype
- the property class to be returned (if possible), not nullflavour
- a string allow symantic differences
in formatting to be communicated (ignored)context
- not nullprotected void handleException(Exception e)
org.apache.commons.beanutils.ConversionException
when conversion fails.e
- the Exception to be handledorg.apache.commons.beanutils.ConversionException
- when conversion failsCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.