How do I subtract minutes from current time

China☆狼群 提交于 2019-12-02 00:52:14

问题


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:


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

use( groovy.time.TimeCategory ) {
    println 10.minutes.ago
}


来源:https://stackoverflow.com/questions/25046910/how-do-i-subtract-minutes-from-current-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!