getDateCount static method

int getDateCount(
  1. int year,
  2. int month
)

计算月份所对应天数

Implementation

static int getDateCount(int year, int month) {
  switch (month) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return 31;
    case 2:
      if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
        return 29;
      }
      return 28;
  }
  return 30;
}