Addition or subtraction on date

We have a nice culture in our company where we sit together on every alternate Saturday and either share new things or we just learn about the technology we are using. This time we discussed about Groovy Meta Programming tricks and we watched the Meta Programming video of Jeff Brown. In that video the handling of Missing Method was really helpful.

Today I got the use case in my project where I need to add/minus the years, months, weeks etc in date. I searched about such methods but couldn’t find the best solution, though Gregorian calendar is one of the option. Then I found a very nice blog on getting past future dates from Aman Aggarwal. So I added the functionality given in the blog into the Date class using Meta Programming