计算指定年份里月份中的天数
代码:
?
public void setDate(int year, int month, int day) {/** 计算当前月份的总天数 */switch (month + 1) { // The month is counted from zero.case 1:case 3:case 5:case 7:case 8:case 10:case 12: days = 31; break;case 4:case 6:case 9:case 11: days = 30; break;default: if (year % 4 != 0)days = 28; else if (year % 100 != 0)days = 29; else if (year % 400 != 0)days = 28; elsedays = 29;} }
?
?