Java 如何判断月份以及月份包含的天数?
java编程 判断月份,判断天数?
private Integer calDayNumbersByMonth(Integer year, Integer month) throws Exception { Tools.log("输入的月份是:" + month); if (month != null) { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; //对于2月份需要判断是否为闰年 case 2: if (year % 4 == 0 && year % 100 != 0) { return 29; } else if (year % 400 == 0){ return 29; } else { return 28; } case 4: case 6: case 9: case 11: return 30; default: return null; } } else { return null; } }