File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Web Services
Bookmark "Error passing in a date object " Watch "Error passing in a date object " New topic
Author

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";

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

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


My free books and tutorials: http://www.slideshare.net/krizsan
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:
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

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