Skip to content

Instantly share code, notes, and snippets.

View tmanolat's full-sized avatar

TILEMAHOS MANOLATOS tmanolat

  • KNOWLEDGE BROADBAND SERVICES SA
View GitHub Profile
@gfrison
gfrison / groovy-date-time-operations
Created February 5, 2011 15:00
How to add months, days, years to a date in Groovy
Groovy also has a Time Category class which gives you DSL style syntax for manipulating dates. Here is an example:
import org.codehaus.groovy.runtime.TimeCategory
now = new Date()
println now
use(TimeCategory) {
footballPractice = now + 1.week - 4.days + 2.hours - 3.seconds
}
println footballPractice
which will produce output like this: