I’m trying to parse the time stamps written in some xml files. Most to the time time stamps are something like 2009-07-22-07:00 but some times I find them something like 2009-07-22Z or 2009-07-22z. Kindly help me how to interpret these Zs and how to parse them. I thing these z or Z is related to the time zone. Any workarounds to parse them just like the typical time stamps?
Share
To add to fvu’s answer: Java unfortunately does not have any built-in method to parse (or format ISO8601 date and time format, and even more unfortunately it is not (easily) possible to parse ISO8601 dates with
java.text.SimpleDateFormat.The well-known and popular Joda Time library does have good support for ISO8601 dates and times.
Edit: Since Java 5, there are classes in the standard API to parse and format dates and times in the standard format often used in XML documents. To parse a date:
Likewise there are methods to format dates into strings.
See the API documentation of those classes for details.