public static void main(String[] args) {
getDateLastDay("2018","1");
}
public static void getDateLastDay(String year, String month) {
//year="2018" month="3"
Calendar calendar = Calendar.getInstance();
// 设置时间,当前时间不用设置
calendar.set(Calendar.YEAR, Integer.parseInt(year));
calendar.set(Calendar.MONTH, Integer.parseInt(month));
System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); //Date,当前月的最后一天
}