How to get the last date of a particular month with JodaTime?

后端 未结 4 1207
礼貌的吻别
礼貌的吻别 2020-12-02 11:36

I need to get the first date (as org.joda.time.LocalDate) of a month and the last one. Getting the first is trivial, but getting the last seems to need some log

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 12:34

    Another simple method is this:

    //Set the Date in First of the next Month:
    answer = new DateTime(year,month+1,1,0,0,0);
    //Now take away one day and now you have the last day in the month correctly
    answer = answer.minusDays(1);
    

提交回复
热议问题