Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error passing in a date object

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm calling Oracle CRM On Demand by generating a WS proxy of its WSDL file. There's a field of date datatype in CRMOD and in the java class, it accepts a Calendar object. Below is my code

Here's my code

1) I have a Date object
2) I found a piece of code on the internet to get the WS 2.0 ISO8601 DateTime format. This method will format my Date object and return a String as below

String dateString = "2011-09-08T00:00:00-0700-07:00";

3)
SimpleDateFormat dfISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
Date dt= dfISO8601.parse(dateString);

4)

Calendar cal = Calendar.getInstance();
cal.setTime(dt);

5) customObject.setDStartDate(cal);

but it kept saying

"The value '11-09-08-07:00' cannot be converted to a date time value.(SBL-DAT-00359)"

It looks like Calendar reverts back to the default date formatting which does not conform to XSD format.

Do you have any idea?

Thanks



 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
How are you calling the web service?
Are you using client artifacts generated by some tool from some web service stack? If so, which tool and which web service stack?
Posting a little code may make the question easier to answer.
Best wishes!
 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I generate WS Proxy (JAX-RPC) using JDeveloper from a WSDL file and call it from within a Java application.

How do you pass in a Calendar object in the XSD format as below?

For Web services v2.0, the data in SOAP requests conforms to XSD data formats.
The XSD dateTime datatype has the format:
yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
For example:
2009-10-10T12:00:00-05:00
represents noon on 10th October 2002, Central Daylight Savings Time, which is equivalent to Eastern
Standard Time in the US.
As a further example:
2009-10-09T17:00:00Z
represents noon on 9th October 2009, UCT, which is equivalent to the GMT time zone.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Are you sure that you are to use JAX-RPC?
If not, then I suggest you give JAX-WS a try - there may issues with the implementation in JAX-RPC that prevents proper serialization of dates and/or calendars.
Best wishes!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic