Skip to content

Instantly share code, notes, and snippets.

@lucastex
Created March 24, 2011 19:01
Show Gist options
  • Save lucastex/885631 to your computer and use it in GitHub Desktop.
Save lucastex/885631 to your computer and use it in GitHub Desktop.
Somando dias na data
Integer.metaClass.propertyMissing = { name ->
if (name == "day" || name == "days") {
return delegate
} else if (name == "month" || name == "months") {
return delegate * 30
} else if (name == "year" || name == "years") {
return delegate * 30 * 12
} else {
throw new MissingPropertyException(delegate)
}
}
println new Date()
println new Date() + 1.day
println new Date() + 10.days
println new Date() + 1.month
println new Date() + 10.months
println new Date() + 1.year
println new Date() + 10.years
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment