commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romualdo Rubens de Freitas" <romuald...@gmail.com>
Subject Re: $$$ [Digester] Converting String do java.util.Date $$$
Date Fri, 19 Oct 2007 20:10:41 GMT
Hi Simon,

Thanks a lot for your quick answer.

Yes, I was debugging Digester source code to see where my XML document was
failing and I've found that code at
org.apache.commons.beanutils.converters.DateTimeConverter.convertToType()
method.

As I said that method has an if statement with the boolean condition:
useLocaleFormat

Your tip is cool, I can register my own conversion object, but I think
it's possible to
configure the conversion made by BeanUtils so that my date format can
be recognized as
BeanUtils docs state, but I don't know how nor where 'cause this
configuration must be
made with Digester (I think).

Can you help with date contents in XML elements/attributes, too ???

TIA.

2007/10/19, simon <simon.kitching@chello.at>:
> 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
> ConvertUtils.convert.
>
> 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?
>
>
> Regards,
>
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Romualdo Rubens de Freitas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message