It's not a secret anymore!*
The moose likes Web Services and the fly likes Error passing in a date object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Error passing in a date object " Watch "Error passing in a date object " New topic

Error passing in a date object

Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
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";

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


Calendar cal = Calendar.getInstance();

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?


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
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!

My free books and tutorials:
Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
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:
represents noon on 10th October 2002, Central Daylight Savings Time, which is equivalent to Eastern
Standard Time in the US.
As a further example:
represents noon on 9th October 2009, UCT, which is equivalent to the GMT time zone.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
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!
I agree. Here's the link:
subject: Error passing in a date object
Similar Threads
JAX-RPC and Calendar question
Date Formatting
Format Date using Calendar
Convert Calendar object to Date object
Possble Calendar bug with daylight saving time