/**
* 方法一
*/

String strDate = "2012-02";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Date date = format.parse(strDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
int days1 = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println("天数为=" + days1);

/**
* 方法二
*/
int days2 = new Date(2012,02,0).getDate();
System.out.println("天数为=" + days2);

 

相关文章:

  • 2021-09-13
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-11-28
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案