此方法可以获取实际月份的天数
public static void main (String[] args) {
int yearIn=2020;
int month=2;
Calendar c=Calendar.getInstance();
c.set(yearIn, month);
int dayOfMonth =c.get(Calendar.DAY_OF_MONTH);
System.out.println(dayOfMonth)
}
解析:new Date(2017,11,0) 表示2017/12/1的前一天,也就是2017/11/30号,而Calendar.DAY_OF_MONTH
是用来获得这一天是在这个月的第多少天,所以 int dayOfMonth =c.get(Calendar.DAY_OF_MONTH)应该等于30,
也就是这个月有30天