我想解析一个GMT日期,比如Wed,2016年10月21日07:28:00 GMT with DateTimeFormatter到Instant.为了创建模式,我使用了官方文档:
DateTimeFormatter
我的代码到目前为止:
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);
但每次我有这个错误:
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)
在索引0是星期三,我使用EEE表示星期几的定义,也有例子表示:Tue;星期二; T.
我也试过低,大写但不成功.怎么了?我忽略了什么吗?