0

Simple question: what format should I use with this date?

2011-10-09T05:06:03.000000Z

This one does not work:

"yyyy-MM-dd'T'HH:mm:ssZZ"

From the manual: "The timestamp is calculated from epoch_ticks (zulu), format=%Y-%m-%dT%H:%M:%S.%fZ"

user3111525
  • 5,013
  • 9
  • 39
  • 64

1 Answers1

1

I think the short answer is "you can't". For some reason Java does not support "Z" as a time zone identifier. You can do a workaround like this though:

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Date d = df.parse("2011-10-09T05:06:03.000000Z");

This assumes that the date will be in UTC and ignores the Z.

Dan Bliss
  • 1,694
  • 13
  • 10