Why LocalDate.plusDays not working here?

后端 未结 2 1773
栀梦
栀梦 2020-12-21 17:38

I\'m trying to split a date range into individual dates in the following way:

private static void splitDates(LocalDate dateFrom, LocalDate dateTo) {
    whil         


        
相关标签:
2条回答
  • 2020-12-21 17:45

    plusDays doesn't alter the original LocalDate, you have to assign the result :

    dateFrom = dateFrom.plusDays(1L);
    
    0 讨论(0)
  • 2020-12-21 17:48

    Because method plusDays doesn't change variable dateFrom. You should do like this:

    dateFrom = dateFrom.plusDays(1L);
    
    0 讨论(0)
提交回复
热议问题