groovysmartthings

How do I subtract minutes from current time


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?


Solution

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

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