gpt4 book ai didi

date - 如何在 Groovy 中的两个日期之间迭代数周?

转载 作者:行者123 更新时间:2023-12-05 00:26:34 25 4
gpt4 key购买 nike

我试图每周从开始到结束迭代日期。目前,我正在编写以下代码。

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

有没有更好的方法?

最佳答案

考虑到您有两个日期 startDateendDate ,这应该可以完成工作:

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

更时髦,不是吗?

关于date - 如何在 Groovy 中的两个日期之间迭代数周?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22005705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com