JAVA中的SimpleDateFormat yyyy和YYYY的区别

在格式化日期中:

YYYY 是 week-based-year,今天就已经 是2020 年了

yyyy是year-of-era ,今天还是 2019 年

week-based-year的解释:

In a week-based-year, each week belongs to only a single year. Week 1 of a year is the first week that starts on the first day-of-week and has at least the minimum number of days. The first and last weeks of a year may contain days from the previous calendar year or next calendar year respectively.

当天所在的周属于的年份,一周从周日开始,周六结束,只要本周跨年,那么这周就算入下一年。

特别的:

不仅Java中,在JavaScript,PHP中都有这个问题。