tags:

views:

149

answers:

1

Is there a way in Groovy to get the duration between two Date objects? The duration format I'm looking for would be something like: 2 days, 10 hours, 30 minutes...

Thanks

+4  A: 

TimeCategory has some methods for getting a duration. You could use it like

use(groovy.time.TimeCategory) {
    def duration = date1 - date2
    print "Days: ${duration.days}, Hours: ${duration.hours}, etc."
}
ig0774
Thanks, worked great!
UltraVi01