Groovy:如何手动创建日期GroovyRuntimeException

Groovy:如何手动创建日期GroovyRuntimeException,groovy,runtimeexception,Groovy,Runtimeexception,我想使用Groovy从web api导出一些数据。因此,我想手动设置一个开始的日期。例如,我想从2020年12月31日开始 因此,我使用了以下代码: import java.time.LocalDateTime; LocalDateTime fromDate = new LocalDateTime(2020, 12, 31, 10, 00); 执行脚本时,我得到一个GroovyRuntimeException: groovy.lang.GroovyRuntimeException: Could

我想使用Groovy从web api导出一些数据。因此,我想手动设置一个开始的日期。例如,我想从2020年12月31日开始

因此,我使用了以下代码:

import java.time.LocalDateTime;
LocalDateTime fromDate = new LocalDateTime(2020, 12, 31, 10, 00);
执行脚本时,我得到一个
GroovyRuntimeException

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.time.LocalDateTime(Integer, Integer, Integer, Integer, Integer)

LocalDateTime
没有公共构造函数。使用以下多种工厂
of()
方法之一:

LocalDateTime fromDate = LocalDateTime.of(2020, 12, 31, 10, 0, 0)
//or
LocalDateTime fromDate = LocalDateTime.of(LocalDate.of(2020, 12, 31), 
                                          LocalTime.of(10, 0, 0))
//etc.

我得到:
无法解析LocalDateTime类。of
不要使用
new