Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • This is very nice to know. I'm still stuck with java 1.6- :( Commented May 16, 2012 at 8:57
  • 1
    Same here about Java 6, but thanks for noting this. Commented May 16, 2012 at 9:01
  • 1
    The correct pattern for the date example of this question should probably be "yyyy-MM-dd'T'HH:mm:ssX" (i.e., just one 'X'). Commented May 16, 2012 at 14:24
  • @PNS You are right - amended. Commented May 16, 2012 at 14:31
  • 13
    If only one X is used, you'll get a truncated time zone, e.g., 2014-03-03-T16:00:00-08. From my reading of docs.oracle.com/javase/7/docs/api/java/text/… (and testing), you want XXX in order to get a properly formatted time zone (at least in terms of what the OP points to, specifically section 3.2.7.3), e.g., "yyyy-MM-dd'T'HH:mm:ssXXX", which gives you 2014-03-03-T16:00:00-08:00. Note the colon-separated time zone info. Commented Mar 4, 2014 at 0:05

lang-java