java.time.format.DateTimeParseException 使用 DateTimeFormatter

All_Safe

我有这个代码:

DateTimeFormatter formatter = new DateTimeFormatterBuilder()
        .appendPattern(DateType.DATE_FORMAT)
        .appendOffset("+HH:mm", "+00:00")
        .toFormatter();
ZonedDateTime.parse("2018-06-09T14:09:30.020+03:00[Europe/Tallinn]", formatter);

DateType.java

public class DateType {

    public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_TIME_ZONE_FORMAT = DATE_FORMAT + "XXX";
}

但是,我运行此代码时出现错误:

java.time.format.DateTimeParseException: Text '2018-06-09T14:09:30.020+03:00[Europe/Tallinn]' could not be parsed at index 10

据我了解,这是因为格式化程序。可能有什么问题?

信噪比

我想知道你为什么不尝试默认解析器。我认为它按预期工作。

String dateTime = "2018-06-09T14:09:30.020+03:00[Europe/Tallinn]";
ZonedDateTime z = ZonedDateTime.parse(dateTime);
System.out.println(z);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

java.time.format.DateTimeParseException

来自分类Dev

使用DateTimeFormatter解析AM / PM时间时,Java 8 DateTimeParseException

来自分类Dev

字符串上的Java java.time.format.DateTimeParseException

来自分类常见问题

嵌套的异常是java.time.format.DateTimeParseException:文本'3030821'

来自分类Dev

dd-MMM-yyyy格式的java.time.format.DateTimeParseException

来自分类Dev

DateTimeFormatter类感知DateTimeParseException

来自分类Dev

为什么Java的java.time.format.DateTimeFormatter#format(LocalDateTime)增加一年?

来自分类Dev

java.time.format.DateTimeParseException:无法在索引5处解析文本“ 2016-2-2”

来自分类Dev

java.time.format.DateTimeParseException:无法在索引21处解析文本

来自分类Dev

错误java.time.format.DateTimeParseException:无法解析,在索引10处找到未解析的文本

来自分类Dev

解析那一年java.time.format.DateTimeParseException

来自分类Dev

Instant.parse和RFC3339串抛出java.time.format.DateTimeParseException

来自分类Dev

java.time.format.DateTimeParseException:尝试解析时区日期时间时

来自分类Dev

使用新的java.time.DateTimeFormatter解析日期和时间

来自分类Dev

java.time.format.DateTimeParseException:文本“周四2019 5月30日 - 02:00 PM”无法在索引0解析

来自分类Dev

使用java.time.DateTimeFormatter格式化Java日期,包括时间偏移

来自分类Dev

由以下原因导致:java.time.format.DateTimeParseException:无法解析文本'2020-05-12 10:23:45',在索引10处找到了未解析的文本

来自分类Dev

线程“主”中的异常java.time.format.DateTimeParseException:无法在索引0处解析文本“ 14 / Oct / 2016 23:09:25.2110 +0530”

来自分类Dev

DateTimeFormatter Java

来自分类Dev

DateTimeFormatter Java

来自分类Dev

时区偏移量的java.time DateTimeFormatter模式

来自分类Dev

使用可选的解析器从joda-time DateTimeFormatter打印

来自分类Dev

使用新的Java 8 DateTimeFormatter进行严格的日期解析

来自分类Dev

Java-DateTimeFormatter-ParseException

来自分类Dev

java.time.DateTimeFormatter:需要始终呈现毫秒的ISO_INSTANT

来自分类Dev

Unicode ICU而非java.time.DateTimeFormatter应该用于国际日期和时间

来自分类Dev

DateTimeParseException用于DateTimeFormatter与图案 “YYYY [-MM [-d [HH [:毫米[:SS [.SSS]]]]]”

来自分类Dev

使用ThreeTenABP的索引0处的DateTimeParseException

来自分类Dev

使用DateTimeFormatter ofPattern解析日期

Related 相关文章

  1. 1

    java.time.format.DateTimeParseException

  2. 2

    使用DateTimeFormatter解析AM / PM时间时,Java 8 DateTimeParseException

  3. 3

    字符串上的Java java.time.format.DateTimeParseException

  4. 4

    嵌套的异常是java.time.format.DateTimeParseException:文本'3030821'

  5. 5

    dd-MMM-yyyy格式的java.time.format.DateTimeParseException

  6. 6

    DateTimeFormatter类感知DateTimeParseException

  7. 7

    为什么Java的java.time.format.DateTimeFormatter#format(LocalDateTime)增加一年?

  8. 8

    java.time.format.DateTimeParseException:无法在索引5处解析文本“ 2016-2-2”

  9. 9

    java.time.format.DateTimeParseException:无法在索引21处解析文本

  10. 10

    错误java.time.format.DateTimeParseException:无法解析,在索引10处找到未解析的文本

  11. 11

    解析那一年java.time.format.DateTimeParseException

  12. 12

    Instant.parse和RFC3339串抛出java.time.format.DateTimeParseException

  13. 13

    java.time.format.DateTimeParseException:尝试解析时区日期时间时

  14. 14

    使用新的java.time.DateTimeFormatter解析日期和时间

  15. 15

    java.time.format.DateTimeParseException:文本“周四2019 5月30日 - 02:00 PM”无法在索引0解析

  16. 16

    使用java.time.DateTimeFormatter格式化Java日期,包括时间偏移

  17. 17

    由以下原因导致:java.time.format.DateTimeParseException:无法解析文本'2020-05-12 10:23:45',在索引10处找到了未解析的文本

  18. 18

    线程“主”中的异常java.time.format.DateTimeParseException:无法在索引0处解析文本“ 14 / Oct / 2016 23:09:25.2110 +0530”

  19. 19

    DateTimeFormatter Java

  20. 20

    DateTimeFormatter Java

  21. 21

    时区偏移量的java.time DateTimeFormatter模式

  22. 22

    使用可选的解析器从joda-time DateTimeFormatter打印

  23. 23

    使用新的Java 8 DateTimeFormatter进行严格的日期解析

  24. 24

    Java-DateTimeFormatter-ParseException

  25. 25

    java.time.DateTimeFormatter:需要始终呈现毫秒的ISO_INSTANT

  26. 26

    Unicode ICU而非java.time.DateTimeFormatter应该用于国际日期和时间

  27. 27

    DateTimeParseException用于DateTimeFormatter与图案 “YYYY [-MM [-d [HH [:毫米[:SS [.SSS]]]]]”

  28. 28

    使用ThreeTenABP的索引0处的DateTimeParseException

  29. 29

    使用DateTimeFormatter ofPattern解析日期

热门标签

归档