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

用户名

这是代码:

LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1451438792953L), ZoneId.of("UTC"));
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.SSS'Z'");
String output = dateTimeFormatter.format(localDateTime);

这是值localDateTime

2015-12-30T01:26:32.953

这是值output

2016-12-30T01:26:32.953Z

为什么要增加一年?

其中java.time.temporal.WeekFields有几种方法,有时会newYearWeek增加年1为什么?

这是一个奇怪的错误。

诺贝

维基百科

[YYYY]表示ISO周编号年份,与传统的公历年份略有不同(请参见下文)。

  1. YYYY 是本年度的ISO-8601样式表示形式。
  2. yyyy 是公历年份的表示形式。

由于两者的计算可以相差+1或-1,因此格式不同。在更多有用的信息YEAR_OF_ERAYEARweekBasedYear

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

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

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

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

来自分类Dev

java.time.format.DateTimeParseException 使用 DateTimeFormatter

来自分类Dev

java.time.format.DateTimeParseException

来自分类Dev

为什么我的.format错误?JAVA文件

来自分类Dev

是什么LocalDateTime.format(DateTimeFormatter)和DateTimeFormatter.format(TemporalAccessor)之间的区别?

来自分类Dev

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

来自分类常见问题

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

来自分类Dev

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

来自分类Dev

Format date time in jQuery

来自分类Dev

一年增加几天-Java

来自分类Dev

time data does not match format

来自分类Dev

为什么给定长度为零的长度,Emacs的format-time-string会返回非午夜值?

来自分类Dev

Java Time API语言环境(一年中的一周)

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

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

来自分类Dev

为什么“ {}”。format(1241.123124)与“ {:g}”。format(1241.123124)不同

来自分类Dev

Displaying time in AM/PM format with Angular grid

来自分类Dev

这是什么 '的String.format( “...”);' 在Java中吗?

来自分类Dev

Remove time zones from a string or format HTTP TIME STRING in coldfusion

来自分类Dev

Python:'{:,}'。format()为什么起作用?

来自分类Dev

为什么String.Format有区别?

来自分类Dev

为什么无法识别FORMAT功能?

来自分类Dev

为什么NumberFormat.format抛出NullPointerException?

来自分类Dev

为什么ticklabel_format不生效?

来自分类Dev

使用java.time查找一年中最后一周的第一天

来自分类Dev

Go的time.Format(布局字符串)参考时间的意义是什么?

Related 相关文章

  1. 1

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

  2. 2

    java.time.format.DateTimeParseException 使用 DateTimeFormatter

  3. 3

    java.time.format.DateTimeParseException

  4. 4

    为什么我的.format错误?JAVA文件

  5. 5

    是什么LocalDateTime.format(DateTimeFormatter)和DateTimeFormatter.format(TemporalAccessor)之间的区别?

  6. 6

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

  7. 7

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

  8. 8

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

  9. 9

    Format date time in jQuery

  10. 10

    一年增加几天-Java

  11. 11

    time data does not match format

  12. 12

    为什么给定长度为零的长度,Emacs的format-time-string会返回非午夜值?

  13. 13

    Java Time API语言环境(一年中的一周)

  14. 14

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

  15. 15

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

  16. 16

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

  17. 17

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

  18. 18

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

  19. 19

    为什么“ {}”。format(1241.123124)与“ {:g}”。format(1241.123124)不同

  20. 20

    Displaying time in AM/PM format with Angular grid

  21. 21

    这是什么 '的String.format( “...”);' 在Java中吗?

  22. 22

    Remove time zones from a string or format HTTP TIME STRING in coldfusion

  23. 23

    Python:'{:,}'。format()为什么起作用?

  24. 24

    为什么String.Format有区别?

  25. 25

    为什么无法识别FORMAT功能?

  26. 26

    为什么NumberFormat.format抛出NullPointerException?

  27. 27

    为什么ticklabel_format不生效?

  28. 28

    使用java.time查找一年中最后一周的第一天

  29. 29

    Go的time.Format(布局字符串)参考时间的意义是什么?

热门标签

归档