Joda time - all mondays between two dates

前端 未结 6 1971
我寻月下人不归
我寻月下人不归 2020-12-16 03:36

I am using Joda time api in a Spring 3.0 project for the very first time. Now I have a start and end date and I want to get the date for all mondays between these two dates.

6条回答
  •  一个人的身影
    2020-12-16 03:54

    I recently developed Lamma which is designed to solve this exact use case:

    Dates.from(2011, 11, 8).to(2011, 12, 30).byWeek().on(DayOfWeek.MONDAY).build();
    

    and you will get a List of:

    Date(2011,11,14)
    Date(2011,11,21)
    Date(2011,11,28)
    Date(2011,12,5)
    Date(2011,12,12)
    Date(2011,12,19)
    Date(2011,12,26)
    

提交回复
热议问题