【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
昨天刷v2ex的时候看到标题YYYY-MM-dd什么bug什么的我都没点进去,今天早上到公司,就有测试和我说测出了日期显示bug,我又重新打开了v站看了一眼,哦,恍然大悟
在格式化日期中:
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中的SimpleDateFormat yyyy和YYYY的区别
来源:oschina
链接:https://my.oschina.net/u/1762811/blog/3151351