学艺不精,以为YYYY
和yyyy
可以一样用,结果翻车了……
根据Oracle Java SE 7的文档,可以知道小写y
指的是年,大写Y
指的是Week Year。但是Week Year是什么东东?
开始无脑引用(参考资料1):
The week of a week-based year can also be defined in different ways.
- Week # 1 contains January 1.
- Week # 1 is the first week to contain a particular day-of-week such as Sunday.
MD,看了一圈下来发现:Week Year基于周的定义来计算年,且在标准Java环境下,Week Year在和Week in year(Letter w
)和Day number of week(Letter u
)联用的情况下才能正常工作。在Y
与别的Letter混用的情况下,别的值不能正常使用,值会被认为是1。(Since you supplied a week-year but did not supply day of week and week in year, those to values have been assumed as 1.
)
不过在Pega环境下,Y
似乎不按照Java基本法发挥作用,“YYYY-MM-DD”居然会被认为是“自然年-月-Day in year”,太神奇了。