//获得某月份的天数
private int getDaysForMonth(int month) {
// month is 0-based
if (month == 1) {
int x400 = month % 400;
if (x400 < 0)
{
x400 = -x400;
}
boolean is29 = (month % 4) == 0 && x400 != 100 && x400 != 200 && x400 != 300;
return is29 ? 29 : 28;
}
if (month == 3 || month == 5 || month == 8 || month == 10)
return 30;
else
return 31;
}
private int getDaysForMonth(int month, int year) {
// month is 0-based
if (month == 1) {
int x400 = month % 400;
if (x400 < 0)
{
x400 = -x400;
}
boolean is29 = (month % 4) == 0 && x400 != 100 && x400 != 200 && x400 != 300;
return is29 ? 29 : 28;
}
if (month == 3 || month == 5 || month == 8 || month == 10)
return 30;
else
return 31;
}