• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can dateTime field format can be controlled ?

 
gcmahesh kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am storing a data with dateTime field with format as "2010-04-20T09:30:47.0+05:00" it get stored successfully but when i retrieve using webservice in response i get it as "2010-04-20T04:30:47.000Z". I want the response in the same way it is stored.
In javaClass i hv used GregorianCalendar as data Type.Is that cause for my problem ?


Thanks in Advance
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahesh,
xsd:dateTime is mapped to java.util.Calendar.
Your stubs on service and client side code should contain accordingly. You need to use java utility methods to format your dates, this has nothing to do with web services.

I see there is a mismatch in the times because of different time zones. You may need to use the right time zone to fix your problem.
 
gcmahesh kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Naren.
But i have 2 webservices one string based webservice and other Object based webservice.
In string based webservice i get the response in the way in wanted.Even for this i m using the same datatype(GregorianCalendar) for the same field. There it works fine but i m facing this problem only in Object based service where it is getting converted to the UTC Those time mismatch is because of this.
Technically they are equal but i dont want it (2010-04-20T09:30:47.0+05:00) to get converted to UTC(2010-04-20T04:30:47.000Z).
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Have you considered trying, or tried, XmlGregorianCalendar?
Best wishes!
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahesh,
Ivan is right!

I am storing a data with dateTime field with format as "2010-04-20T09:30:47.0+05:00" it get stored successfully but when i retrieve using webservice in response i get it as "2010-04-20T04:30:47.000Z".

1. Map your first date to GregorianCalendar (as xsd:dateTime is mapped to java.util.Calendar), say this is "date1"
2. Create GregorianCalendar from your second date...

Now, check if "date1" and "date2" are equal.
 
gcmahesh kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Ivan and Naren.
This "((2010-04-20T09:30:47.0+05:00) to get converted to UTC(2010-04-20T04:30:47.000Z))" worked.
But i got a new problem from that.
when i am using this code
calendar = factory.newXMLGregorianCalendar(ConvertToDateFormat("2009-09-12 09:30:47.000000 +00:00")).toGregorianCalendar();
I get the output as 2009-09-12T09:30:47.000+00:00 But i need 2009-09-12T09:30:47.000000Z. i.e only if +00:00 is the time zone then Z should be appended.
Again this works fine with String based wsdl only object based wsdl is having this timestamp problem.

Thanks in Advance


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic