You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "vincent.daubry@aliceadsl.fr" <vi...@aliceadsl.fr> on 2006/09/06 14:53:57 UTC

Unparseable date: ""

Hi !

I'm new to betwixt and i would need some help to convert
date fields from xml to java. Here is my problem :
I have an object with some Date fields in it. I generate an
xml file using betwixt, everything works fine.
When i try to parse the xml generated and get a java object,
i get an error if a date field is empty (i.e: if date was
null when i convert it to xml)

ERROR digester.Digester  - Body event threw exception
org.apache.commons.beanutils.ConversionException: String to
object conversion failed: Unparseable date: ""

if no date field is empty, then it works. Here is the XML i
tried to convert :

<creditBO id="1">
<nmintx/>
<tf0013>0.04529</tf0013>
<ddve00/>
<idcvp1>0000154</idcvp1>
<idagb4>936</idagb4>
<mtehu4>30.83</mtehu4>
<id>272</id>
<rfcrc1>501623270102</rfcrc1>
<cdmeop>EUR</cdmeop>
<dfeh31/>
<txit06>3.31</txit06>
<datr11>Fri Jun 02 00:00:00 CEST 2006</datr11>
<vd0010/>
<txmat2>0.0</txmat2>
<mtdk20>300.0</mtdk20>
<iycct1>N</iycct1>
<mtau13>100000.0</mtau13>
<idUtlQqo>2</idUtlQqo>
<idcr00>00333465399</idcr00>
<mtehep2>979.98</mtehep2>
<txitm2>3.3100000616961</txitm2>
<tygck2/>
<typu32>52F07153</typu32>
<mteha5>1010.81</mteha5>
<natx12>1</natx12>
<typee9>M</typee9>
<idop11/>
<ddam05/>
<ducr01>120</ducr01>
<sdmi05/>
<kb0025/>
<dfmik1/>
<dtMajQqo>Mon Sep 04 14:44:32 CEST 2006</dtMajQqo>
<dtmaj>Mon Sep 04 14:44:32 CEST 2006</dtmaj>
<rdpcg2>50856</rdpcg2>
<iddsy1>50162327</iddsy1>
<txefc1/>
<contraintes/>
<dtCreation>Mon Sep 04 14:44:32 CEST 2006</dtCreation>
<daexp3/>
<tf0010>0.04438</tf0010>
</creditBO>


ddve00 is a date field :
if i have <ddve00>Fri Jun 02 00:00:00 CEST 2006</ddve00> it
works
if i have <ddve00/> is crashes.

I looked on the mailing list, and all i found was a message
about registering a custom date converter for ConvertUtils,
with something like this :
MyDateConverter converter = new MyDateConverter();
ConvertUtils.register(converter, java.util.Date.class);

I think there must be an easier solution, i just need to be
able to get null when the xml contains "" for a date.
And if there is no other solution, where can i find some
docs or exemple on creating a date Converter.

Thanks in advance !
Vincent

--------------------- ALICE SECURITE ENFANTS ---------------------
Protégez vos enfants des dangers d'Internet en installant Sécurité Enfants, le contrôle parental d'Alice.
http://www.aliceadsl.fr/securitepc/default_copa.asp



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