axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 16800] - simpleTypes based on date/dateTime serialization problems (wsdl2java)
Date Fri, 08 Aug 2003 16:15:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16800>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16800

simpleTypes based on date/dateTime serialization problems (wsdl2java)





------- Additional Comments From nycelina888@aol.com  2003-08-08 16:15 -------
I, too, also experienced a similar problem. In order to bypass, I modified the 
beans that were automatically created by wsdl2java.
Specifically to the dateTime problem: the following is an example of the 
datetime we use in our xml messages :
 2003-08-01T12:30:13

However, the Calendar object is not able to parse this date. So I modified the 
bean to use the simpledateformat class to first parse the date and then set the 
date time in the calendar object. Recall that the Months in the calendar object 
are zero based. So I had to add one to the month.

Also note that the toString() method will not convert it back into the original 
yyyy-MM-dd'T'HH:mm:ss format. So I had to re-write that method as well.
Here's a snippet:
    java.util.Calendar value;
    ....

    // Simple Types must have a toString for serializing the value
    public java.lang.String toString() {
		/**
		return value == null ? null : value.toString();
		**/
		// MODIFIED BY SLEY TO RETURN THE DATE/TIME IN THE CORRECT 
FORMAT.
		// We will return the date / time in the following format : 
yyyy-MM-dd'T'HH:mm:ss
		if(value == null)
			return null;
		else {
			String result_str = value.get(java.util.Calendar.YEAR) 
+ "-" + value.get(java.util.Calendar.MONTH) + "-" + value.get
(java.util.Calendar.DATE) + "T" + 
				value.get(java.util.Calendar.HOUR_OF_DAY) + ":" 
+ value.get(java.util.Calendar.MINUTE) +":" + value.get
(java.util.Calendar.SECOND);
			return result_str;
		}
    }

Mime
View raw message