commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <>
Subject Re: [Commons Digester 1.6] Custom properties class converters
Date Tue, 01 Mar 2005 20:44:07 GMT
There is no default converter for java.util.Date precisely because the
desired conversion is going to be both Locale and desired-format
dependent, so registering your own is the right general approach.

For the YYYY-MM-DD date format in particular, that happens to be the
default String format for a java.sql.Date, for which there is a
default converter registered.


On Tue, 1 Mar 2005 15:27:59 -0500, Slonim, Greg (Contractor)
<> wrote:
> When Digester is populating properties on the bean it uses
> org.apache.commons.beanutils.BeanUtils.populate(Object, Map) to populate
> object's values. BeanUtilsBean uses various implementations of
> org.apache.commons.beanutils.Converter to convert the values from
> Strings to particular types of objects. Sometimes the default converters
> do not work as intended. Example: I have java.util.Date fields in my
> bean among other things. XML data is coming in in format yyyy-MM-dd and
> it breaks the conversion. I have to manually register
> DataLocaleConverter for this to work. Is there an elegant way to solve
> this problem without explicitly doing
> ConvertUtils.register(new DateLocaleConverter(null, Locale.US,
> "yyyy-MM-dd"), Date.class);
> in my code?
> Regards,
> Greg Slonim
> Senior Software Consultant
> Finance and Portfolio Technologies
> Fannie Mae, Washington DC
> 202-752-3820
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message