以下代码片段
Instant.parse("2023-08-08T00:00:00+02:00")
按照java-17中的预期编译和执行。但是,当使用java-8执行时,会引发以下异常
java.time.format.DateTimeParseException: Text '2023-08-01T00:00:00+02:00' could not be parsed at index 19
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.Instant.parse(Instant.java:395)
...
我的问题是为什么?java.timeapi有什么变化吗?
请注意,我确实知道解决这个问题的方法,下面的代码在java-8中工作
OffsetDateTime.parse("2023-08-01T00:00:00+02:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME).toInstant()
它产生了所需的结果。我很想知道在java时间api实现中,行为是否已经改变?