0

This is what I tried so far but is not working: This is the format of the date return by the Drive api's json response 2014-04-29T17:58:02.437Z

final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
System.out.println(df.parse("2014-04-29T17:58:02.437Z"));

What is the correct way to convert it?

  • Take a look [here](http://stackoverflow.com/questions/2580925/simpledateformat-parsing-date-with-z-literal) – perencia Apr 29 '14 at 19:52
  • In addition to the answers above it's worth noting that (if it's an option for you) Java 8's new Date/Time API handles ISO-8601 natively. – chut Apr 29 '14 at 19:53

1 Answers1

0

Quick suggestion for:

final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.parse("2014-04-29T17:58:02.437Z"));

As you see, Z is simply set by GMT, while you was not parsing 437 milliseconds.

Works for me, just tried it out!

TSB99X
  • 3,260
  • 2
  • 18
  • 20