Reputation: 596
use(TimeCategory) {(1.year + 2.months + 3.hours).toMilliseconds() }
Any suggestions on how to get that in seconds (maintaining the level of grooviness)?
Upvotes: 1
Views: 72
Reputation: 19702
You can add a closure to the groovy.time.TimeDatumDependentDuration
class to hide the conversion to seconds:
TimeDatumDependentDuration.metaClass.toSeconds = { delegate.toMilliseconds() / 1000 }
and then:
use(TimeCategory) { (1.year + 2.months + 3.hours).toSeconds() }
will return seconds.
Upvotes: 1