DateTimeFormatter doesn't parse custom date format

Viewed 5760

I have an issue with java DataTimeFormmater. I feel that I missed something but cannot figure out what exactly.

String format = "yyyy-MM-dd'T'HH:mm:ss[.S]'T'zxxx";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);

String date = "2017-07-05T12:28:36.4TGMT+03:00";

System.out.println(formatter.format(ZonedDateTime.now()));
System.out.println(formatter.parse(date));

The code above produces string of the current ZonedDateTime and attempts to parse date time string with the same date formatter. Result that it successfully produces 2017-07-05T06:07:51.0TCDT-05:00 but fails to parse 2017-07-05T12:28:36.4TGMT+03:00

My goal is to parse 2017-07-05T12:28:36.4TGMT+03:00 and come up with appropriate DateTimeFormatter.

2 Answers
Related