0

Why this line

new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse("2016-09-19T17:30:48.743Z")

is throwing parse exception ?

Piyush
  • 599
  • 1
  • 7
  • 16
  • Side note: consider to use the new Date and Time API. – Puce Sep 18 '16 at 17:49
  • `new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse("2016-09-19T17:30:48.743Z");` Try using this way. – chalitha geekiyanage Sep 18 '16 at 17:54
  • Your date string should not have "Z" in it, but should have a time zone value, like "-0700" or "PDT", for instance: `f2.parse("2001-07-04T12:08:56.235PDT");` or `f2.parse("2001-07-04T12:08:56.235-0700");` – StvnBrkdll Sep 18 '16 at 18:11
  • This should help you if you are on Java 7 or later: `new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX")` - using pattern symbol X which can interprete the literal "Z" as UTC+00:00. – Meno Hochschild Sep 19 '16 at 04:21

0 Answers0