且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java.util.calendar中的默认字段值错误

更新时间:2022-12-05 17:20:40

从0开始使用日历不是从1开始

Month starts from 0 when you use calendar not from 1

根据 javadoc


表示月份的get和set字段号。这是特定于日历的值。一年中的第一个月在格里高利和朱利安日历是JANUARY是0;最后一次取决于一年中的月数。

Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.