Created
May 1, 2014 11:32
-
-
Save timyates/527e116c225b23c89e16 to your computer and use it in GitHub Desktop.
Quick metaClass addition to get Java 8 LocalDate to play with Groovy ranges
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
// Requires Groovy 2.3 and Java 8 | |
import java.time.* | |
// Add a next() method | |
LocalDate.metaClass.next = { delegate.plusDays( 1 ) } | |
// Then print the next two weeks worth of dates | |
(LocalDate.now()..LocalDate.now().plusWeeks( 2 )).each { | |
println it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment