String str = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"))
.format(new Date());
Calendar calendar = Calendar.getInstance(Locale.CHINA);
calendar.setTime(new Date());
int month = calendar.get(Calendar.MONTH) + 1;
int year = calendar.get(Calendar.YEAR);
int totalDay = calendar.getActualMaximum(Calendar.DATE);
.format(new Date());
Calendar calendar = Calendar.getInstance(Locale.CHINA);
calendar.setTime(new Date());
int month = calendar.get(Calendar.MONTH) + 1;
int year = calendar.get(Calendar.YEAR);
int totalDay = calendar.getActualMaximum(Calendar.DATE);
System.out.println(totalDay);
getActualMaximum函数。主要是用于获取一个指定日期的当月总天数