axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ley, Selena (GMI/CPR Dev.)" <>
Subject RE: Date Deserialization Error
Date Mon, 11 Aug 2003 19:18:25 GMT
I realized what the cause is:
the wsdl2java generates the following constructor for the date object:

    public DateOfBirth(java.lang.String value) {
        try {
            this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);
        catch (java.text.ParseException e){
            throw new java.lang.RuntimeException(e.toString());

This differs than what is used by the to deserialize the values from
the xml instance document.
The work-around : 

    // Simple Types must have a String constructor
    public Date(java.lang.String value) {
        try {
            this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);
        catch (java.text.ParseException e){
            throw new java.lang.RuntimeException(e.toString());
		java.text.ParsePosition pos = new java.text.ParsePosition(0);
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
		this.value = sdf.parse(value, pos);


Can someone include this in the nightly builds?

-----Original Message-----
From: Ley, Selena (GMI/CPR Dev.) []
Sent: Monday, August 11, 2003 3:06 PM
Subject: Date Deserialization Error

I'm using the latest Axis 1.1 (nightly build for 8/10/2003). I see a lot of the previous bugs
from beta 2 version, which is great! many thanks!

My xml schema has the following element defined : 
<xs:element name="DateOfBirth" type="DateOfBirth" /> 
<xs:simpleType name="DateOfBirth"> 
<xs:restriction base="xs:date" /> 

I am able to create use the wsdl2java to create the java beans. However, when I'm testing
with a sample message with the following snippet

.. I receive the following error:

Reading Msg from Individual.xml
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "1975-08
        at org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDe
        at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl
        at org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseri
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
        at org.apache.axis.message.MessageElement.getValueAsType(MessageElement.
        at org.apache.axis.message.MessageElement.getValueAsType(MessageElement.
        at BeanDeserializerTester.main(
MIFException: java.text.ParseException: Unparseable date: "1975-08-06"

I checked the DateDeserializer and the simpledateformat used to parse the date is correct
for this date. 

View raw message