I would like to parse an GMT-date like Wed, 21 Oct 2016 07:28:00 GMTwith DateTimeFormatter into an Instant. To create the pattern i used the official documentation: DateTimeFormatter
My code so far:
String date = "Wed, 21 Oct 2016 07:28:00 GMT";
DateTimeFormatter gmtFormat = DateTimeFormatter.ofPattern("EEE' dd LLL yyyy HH:mm:ss '''");
TemporalAccessor parsed = gmtFormat.parse(date);
Instant a = Instant.from(parsed);
System.out.println(a);
But every time i've got this error:
Exception in thread "main" java.time.format.DateTimeParseException: Text 'Wed, 21 Oct 2016 07:28:00 GMT' could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1777)
At index 0 is Wed, I used EEE which represents day-of-week by definition, there are also examples which represent: Tue; Tuesday; T.
I've also tried lower-, and uppercase but not successfully. What is wrong? Did I overlook something?
Unsupported field: DayOfWeek