Roll over the month of dates using LocalDate in Java?

后端 未结 1 1102
梦如初夏
梦如初夏 2020-12-22 08:48

I am designing a booking system in java that only has to handle dates for the year 2015 and using the LocalDate class, a booking consists of a start date and a duration e.g.

相关标签:
1条回答
  • 2020-12-22 09:42

    Assuming you're using Java 8, why not use LocalDate#plusDays?

    LocalDate startDate = LocalDate.of(2015, 5, 26);
    LocalDate endDate = startDate.plusDays(7);
    
    System.out.println(endDate);
    

    Which outputs 2015-06-02

    0 讨论(0)
提交回复
热议问题