When you have TimeCategory do calculation and return duration difference you will get it took 1.001 seconds for example.. To get rid of the milliseconds I used this hack, take from Tim Yates here:
http://stackoverflow.com/questions/16716802/how-to-format-time-durations-in-groovy
A slight tweak to set millseconds to 0 then parse out .000 from output...
private String getDuration(Date startDate,Date endDate) {
if (startDate && endDate) {
//return TimeCategory.minus(endDate, startDate)
TimeDuration customPeriod = use(TimeCategory ) {
customDuration( endDate - startDate )
}
return customPeriod.toString().replace('.000','')
}
}
TimeDuration customDuration( TimeDuration tc ) {
// Replacing tc.mills with 0 then parsing it out above
new TimeDuration( tc.days , tc.hours, tc.minutes, tc.seconds, 0)
}
Tim is a legend :)