Java计算指定年月的日期数

/**
  *
  * @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
发表评论
你没有权限发表留言!