Java计算指定年月的日期数
作者:51itcn 日期:2010-03-17
/**
*
* @param year
* @param month
* @return
*/
public static int maxDayOfMonth(int year, int month) {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
boolean isRunYear = (year % 400 == 0)
|| (year % 4 == 0 && year % 100 != 0);
return isRunYear ? 29 : 28;
default:
return 31;
}
}
*
* @param year
* @param month
* @return
*/
public static int maxDayOfMonth(int year, int month) {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
boolean isRunYear = (year % 400 == 0)
|| (year % 4 == 0 && year % 100 != 0);
return isRunYear ? 29 : 28;
default:
return 31;
}
}
发表评论
你没有权限发表留言!
上一篇
下一篇

文章来自:
Tags: 查看次数: 274