Groovy web console

subscribe to the feed Subscribe
to this
site
ejemplo de timecategory (via #groovywebconsole)
tweet this snippet Tweet
this
script

ejemplo de timecategory

Published 10 months ago by Ignacio
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
use(groovy.time.TimeCategory)  {     
def horaEnUnMinuto = 1.minute.from.now            
def horaHaceDiezHoras = 10.hours.ago      
def hoyHaceTresMeses = Date.newInstance() - 3.months 

println "horaEnUnMinuto : ${horaEnUnMinuto .format("dd/MM/YYYY HH:mm:ss")}" 
println "horaHaceDiezHoras: ${horaHaceDiezHoras.format("dd/MM/YYYY HH:mm:ss")}" 
println "hoyHaceTresMeses: ${hoyHaceTresMeses.format("dd/MM/YYYY HH:mm:ss")}" 
}