Skip to content

Instantly share code, notes, and snippets.

@timyates
Created May 1, 2014 11:32
Show Gist options
  • Save timyates/527e116c225b23c89e16 to your computer and use it in GitHub Desktop.
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
// 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