How to iterate over weeks between two dates in Groovy?

I try to iterate over dates from start to finish every week. I am currently writing the following code.

def current=startDate
    while (current <= endDate) {
        log.debug "Week: ${current}"
        current=current+7
    }

Is there a more expensive way?

+3
source share
1 answer

Given that you have two dates startDateand endDatethis should complete the task:

(startDate..endDate).step(7) { println it }

groovier, right?

+5
source

All Articles