Start and end date of a current month

后端 未结 12 2208
我寻月下人不归
我寻月下人不归 2020-11-29 03:08

I need the start date and the end date of the current month in Java. When the JSP page is loaded with the current month it should automatically calculate the start and end d

12条回答
  •  醉梦人生
    2020-11-29 03:56

    If you have the option, you'd better avoid the horrid Java Date API, and use instead Jodatime. Here is an example:

    LocalDate monthBegin = new LocalDate().withDayOfMonth(1);
    LocalDate monthEnd = new LocalDate().plusMonths(1).withDayOfMonth(1).minusDays(1);
    

提交回复
热议问题