This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 13884
    
  10

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 7 API documentation
Scala Notes - My blog about Scala
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get user defined timezone using XMLGregorianCalendar.
 
Similar Threads
Date, Calendar and TimeZones
how to set 2011-11-06T14:34:16.679+02:00 into XMLGregorianCalendar
How to add JAXB customization to a particular element of an xsd?
Parsing XML datetime in Android
Handling a strange date format