Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Groovy TimeCategory使用变量添加分钟数_Groovy - Fatal编程技术网

Groovy TimeCategory使用变量添加分钟数

Groovy TimeCategory使用变量添加分钟数,groovy,Groovy,如何向currentDate添加分钟数。 我可能会加上1440多分钟 def AddMinutes = 1445 currentDate = new Date(); println currentDate use( TimeCategory ) { NewCurrentDate = currentDate + AddMinutes.minutes // fails NewCurrentDate = currentDate + 1445.minutes // works } printl

如何向currentDate添加分钟数。 我可能会加上1440多分钟

def AddMinutes = 1445
currentDate  = new Date();
println currentDate
use( TimeCategory ) {
  NewCurrentDate = currentDate + AddMinutes.minutes // fails
  NewCurrentDate = currentDate + 1445.minutes // works
}
println currentDate

Tue Feb 23 15:09:13 CET 2016
Wed Feb 24 15:14:13 CET 2016

为我工作。。。除了没有打印出
newCurrentDate
(注:小写字母表示变量名,否则Groovy可能会感到困惑,并认为您对类感兴趣,但这不是问题所在)


我发现我需要确保
addMinutes
int
。所以我在之前的脚本中添加了以下内容:

addMinutes = addMinutes.toInteger()
现在它开始工作了

addMinutes = addMinutes.toInteger()