Groovy web console

subscribe to the feed Subscribe
to this
site
Difference between two system time (via #groovywebconsole)
tweet this snippet Tweet
this
script

Difference between two system time

Published 3 months ago by Mak with tags time sleep timeduration
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.time.*

def date=new Date()
String timePart = date.format("HH:mm:ss")
println("Current Time:" + timePart)
sleep(2000)
println("After 1 sec")
def date2=new Date() 
String timePart2=date2.format("HH:mm:ss")
println("Current Time:" + timePart2)
println("diff: "  + timePart2-timePart)
TimeDuration duration = TimeCategory.minus(date2, date)
println duration
if(duration.seconds>2)
println("don't send")
else
println("send")