//getDayMouth()
public int getDayMouth(int year,int mouth){
int num=0;
switch(mouth){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
num=31;
break;
case 4:
case 6:
case 9:
case 11:
num=30;
break;
case 2:
num = this.isLeapYear(year)?29:28;
break;
default:
System.out.println("非法月份");
break;
}
return num;
}
//定义方法isLeapYear()方法判断指定的年份是否为闰年
public boolean isLeapYear(int year){
if((year%4==0)&&(year%100!=0)||(year%400==0))
return true;
else
return false;
}