小编Ami*_*dal的帖子

DateTimeParseException:无法在索引2处解析文本

现在我真的很困惑,为什么以下代码片段导致DateTimeParseException。

public static void main(String[] args) {
        java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz");
        String date = "Mon, 10 Sep 2018 23:57:09 UTC";
        System.out.println(dtf.parse(date));
}
Run Code Online (Sandbox Code Playgroud)

引发以下异常:

Exception in thread "main" java.time.format.DateTimeParseException: Text 'Mon, 10 Sep 2018 23:57:09 UTC' could not be parsed at index 2
    at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1777)
    at com.sample.binding.bitronvideo.driver.BitronVideoRecordingDriver.main(BitronVideoRecordingDriver.java:448)
Run Code Online (Sandbox Code Playgroud)

我将非常感谢您的进一步帮助。

谢谢阿米特

java datetime java-8

0
推荐指数
1
解决办法
3555
查看次数

标签 统计

datetime ×1

java ×1

java-8 ×1