Last active
March 22, 2019 12:54
-
-
Save dariogabriel113/cac2236c5068fc74decc0cb71b1d14fd to your computer and use it in GitHub Desktop.
Add/Subtract Date Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use (groovy.time.TimeCategory) { | |
//Example of Add Date 20 days from now | |
println new Date() | |
println 20.days.from.now | |
//Example of Add Date 3 months from now | |
println new Date() | |
println 3.months.from.now | |
//Example of Add Date 2 years from now | |
println new Date() | |
println 2.years.from.now | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use (groovy.time.TimeCategory) { | |
//Example of Add Time 10 hours from now | |
println new Date() | |
println 10.hours.from.now | |
println " " | |
//Example of Add Time 15 minutes from now | |
println new Date() | |
println 15.minutes.from.now | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use (groovy.time.TimeCategory) { | |
Date date = new Date() | |
//Example of Subtract Date 10 days from now | |
println date | |
println date-10.days | |
//Example of Subtract Date 3 weeks from now | |
println date | |
println date-3.weeks | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use (groovy.time.TimeCategory) { | |
Date date = new Date() | |
//Example of Subtract Time 10 minutes from now | |
println date | |
println date-15.minutes | |
//Example of Subtract Time 45 hours from now | |
println date | |
println date-45.hours | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment