How do I obtain the number of days within a given month using Joda-Time?

后端 未结 4 1250
离开以前
离开以前 2020-12-28 12:04
30 days hath September,
   April, June and November,
 All the rest have 31,
   Excepting February alone
(And that has 28 days clear,
   With 29 in each leap year).
<         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 12:18

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.MONTH, yourMonth);
    cal.set(Calendar.YEAR, yourYear);
    cal.getActualMaximum(Calendar.DAY_OF_MONTH); // <-- the result!
    

提交回复
热议问题