my dog learned polymorphism*
The moose likes Java in General and the fly likes how to get user defined timezone using XMLGregorianCalendar. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to get user defined timezone using XMLGregorianCalendar." Watch "how to get user defined timezone using XMLGregorianCalendar." New topic
Author

how to get user defined timezone using XMLGregorianCalendar.

rajashree loganayagi
Greenhorn

Joined: Apr 12, 2011
Posts: 20
Hi,

I have a string 'date' with a value "2011-08-10T00:00:00-06:00"(Format:yyyy-MM-dd'T'HH:mm:ss+timezone). My requirement is to parse the string into the XMLGregorianCalendar where i cannot able to parse the timezone values(-06:00). It throws "NumberFormatException".

Please suggest any solution.



Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14270
    
  21

How are you doing the parsing? Note that SimpleDateFormat does not support the ISO 8601 format that's the standard for XML properly.

This works:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
rajashree loganayagi
Greenhorn

Joined: Apr 12, 2011
Posts: 20
I done the parsing using SimpleDateFormat. After using your code it works fine now.

Thank you.
 
Consider Paul's rocket mass heater.
 
subject: how to get user defined timezone using XMLGregorianCalendar.