我如何从当前时间减去分钟数 [英] How do I subtract minutes from current time

查看:368
本文介绍了我如何从当前时间减去分钟数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从当前时间减去10分钟,但是我无法在查找到的文档中找到正确的语法。



到目前为止, / p>

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

并在SmartThings IDE



java.lang.NullPointerException @行53



也许IDE不支持这个库?什么是下一个最好的计算方法?

c $ c>应该给你要找的东西

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


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?

解决方案

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

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

这篇关于我如何从当前时间减去分钟数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆