遍历 LocalDate 范围 groovy 列表

Iterating through LocalDate range groovy list

提问人:developer 提问时间:7/20/2023 最后编辑:developer 更新时间:7/21/2023 访问量:49

问:

这曾经在 Groovy 3.x 版本下工作,但在 4.x 中失败

    LocalDate startDate = LocalDate.of(2023, Month.JULY, 1)
    LocalDate endDate = LocalDate.of(2023, Month.JULY, 31)
    LocalDate[] businessDates = (startDate..endDate).collect()
    businessDates.stream().forEach { print it }
Caught: groovy.lang.MissingMethodException: 
No signature of method: java.time.LocalDate.next() is applicable for argument types: () values: []
Possible solutions: get(java.time.temporal.TemporalField), wait(), now(), wait(long), now(java.time.Clock), now(java.time.ZoneId)
groovy.lang.MissingMethodException: 
No signature of method: java.time.LocalDate.next() is applicable for argument types: () values: []
Possible solutions: get(java.time.temporal.TemporalField), wait(), now(), wait(long), now(java.time.Clock), now(java.time.ZoneId)
    at Main.run(Main.groovy:4)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

关于如何解决这个问题的任何想法?

时髦的 本地日期

评论

0赞 daggett 7/21/2023
适合我 - Groovy 4.0.9
0赞 daggett 7/21/2023
也许您错过了带有 LocalDate 扩展的 jar?
0赞 developer 7/21/2023
谢谢 - 我在 Eclipse IDE 中使用 jdk 11,所以它可能与类路径有关

答: 暂无答案