Posted By

narkisr on 02/04/09


Tagged

date groovy ranges


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

laurenceosx
michaelss


Groovy date ranges


 / Published in: Groovy
 

Groovy ranges works on dates also! (http://kousenit.wordpress.com/2009/02/02/groovy-groundhogs/)

  1. def cal = Calendar.instance
  2. cal.set(2009,Calendar.FEBRUARY,2)
  3. def ghday = cal.time
  4. cal.set(2009,Calendar.MARCH,21)
  5. def spring = cal.time
  6. def days = (ghday..spring).size()
  7. println "Between Feb 2 and Mar 21, there are $days days"
  8. // will print Between Feb 2 and Mar 21, there are 48 days

Report this snippet  

You need to login to post a comment.