How do I subtract minutes from current time

2019-02-25 05:47发布

I am trying to subtract 10 minutes from the current time, but I cant find the proper syntax in the documentation I have looked up

I have this so far

def deltaMinutes = 10
use(TimeCategory) {
    def nowTime = new Date() - deltaMinutes.minutes
    log.debug nowTime
}

and get this in the SmartThings IDE

java.lang.NullPointerException @ line 53

Perhaps the IDE doesnt support this library? What would be the next best method for calculating this?

1条回答
疯言疯语
2楼-- · 2019-02-25 06:00

10.minutes.ago should give what you are looking for

use( groovy.time.TimeCategory ) {
    println 10.minutes.ago
}
查看更多
登录 后发表回答