simpledateformat parsing date with 'Z' literal
Posted
by DanInDC
on Stack Overflow
See other posts from Stack Overflow
or by DanInDC
Published on 2010-04-05T20:17:08Z
Indexed on
2010/04/05
20:23 UTC
Read the original article
Hit count: 423
I am trying to parse a date that looks like this:
2010-04-05T17:16:00Z
This is a valid date per http://www.ietf.org/rfc/rfc3339.txt. The 'Z' literal "imply that UTC is the preferred reference point for the specified time."
If I try to parse it using SimpleDateFormat and this pattern:
yyyy-MM-dd'T'HH:mm:ss
It will be parsed as a Mon Apr 05 17:16:00 EDT 2010
SimpleDateFormat is unable to parse the string with these patterns:
yyyy-MM-dd'T'HH:mm:ssz
yyyy-MM-dd'T'HH:mm:ssZ
I can explicitly set the TimeZone to use on the SimpleDateFormat to get the expected output, but I don't think that should be necessary. Is there something I am missing? Is there an alternative date parser?
© Stack Overflow or respective owner