Wednesday, October 13, 2010

Time durations

Some code that shows durations and works nicely as a timer
    import groovy.time.*

    def timeStart = new Date()
    // Some code you want to time
    def timeStop = new Date()
    TimeDuration duration = TimeCategory.minus(timeStop, timeStart)
    println duration
This will give you the time in hours, minutes, seconds

1 comment: