0

I have a date string inside of a json that I need to parse but I cant get it to work. My date string looks like this : 2018-04-06T10:22:47.643271+02:00

Here is a snippet of the code that parses the date. However this throws an exception java.text.ParseException: Unparseable date: "2018-04-06T10:22:47.643271+02:00"

So far I was able to find that Java does not support fractions of milliseconds, is that really the case here or do I have the format string wrong? Side note I cant change the API response to more palatable date string for java.

Record lastRecord = new Record();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
lastRecord.Time = format.parse(lastStateJson.getString("time"));
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Erwin32
  • 58
  • 6

1 Answers1

1

Never mind me. Turns out I needed correct length of the milliseconds part.

"yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX"
Erwin32
  • 58
  • 6