commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simon <>
Subject Re: $$$ [Digester] Converting String do java.util.Date $$$
Date Fri, 19 Oct 2007 19:53:58 GMT
On Fri, 2007-10-19 at 16:14 -0300, Romualdo Rubens de Freitas wrote:
> Hi All,
> I'm facing a problem with date conversion. My XML document has an element whose
> value has the format dd/MM/yyyy (brazilian date format). When Digester
> tries to convert
> the value to a date I get an exception stating:
> <code>
> 19/10/2007 16:05:31
> org.apache.commons.beanutils.converters.DateTimeConverter toDate
> WARNING:     DateConverter does not support default String to 'Date' conversion.
> 19/10/2007 16:05:32
> org.apache.commons.beanutils.converters.DateTimeConverter toDate
> WARNING:     (N.B. Re-configure Converter or use alternative implementation)
> 19/10/2007 16:05:32 org.apache.commons.digester.Digester endElement

Just use
  ConvertUtils.register(converter, Date.class)
where converter is your own implementation that handles dates however
you want. Digester simply calls the static beanutils method

Ideally, digester would have a ConvertUtils *instance* rather than
relying on the static singleton but that's old history. And in practice
no-one has ever cared.

> SEVERE: End event threw exception
> org.apache.commons.beanutils.ConversionException: DateConverter does
> not support default String to 'Date' conversion.
> </code>
> In the middle of the msgs above there is one that called my attention:
> N.B. Re-configure Converter or use alternative implementation
> According BeanUtils docs I can do that, but I didn't find any
> information on how to do that
> with Digester.
> Debugging Digester source code I've found
> DateTimeConverter.convertToType() method
> that has the following "if (useLocaleFormat) ..." which, I guess,
> could do the job, but I
> don't know how to setup locale info so that the conversion can be done.

Hmm.. I don't remember any code like that. What class is that in? Are
you sure you're not looking at code inside beanutils?



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

View raw message