Misc. experiments in groovy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
596 B

9 years ago
  1. import groovy.time.TimeCategory
  2. rt = Runtime.getRuntime()
  3. threads = rt.availableProcessors()
  4. def now = new Date()
  5. def then = new Date().parse('yyyy-MM-dd-hh','2015-09-23-18')
  6. def cruise = Calendar.instance
  7. cruise.set(2015,9,5,16,0,0)
  8. use TimeCategory, {
  9. println "Current DateTime: " + now
  10. def c = then - now
  11. def b = cruise.time - now
  12. println "My contract ends in ${c.days.intdiv(7)} weeks, ${c.days % 7} days, ${c.hours +1} hours."
  13. print "Our Bahama cruise leaves the port in "
  14. println "${b.days.intdiv(7)} weeks, ${b.days % 7} days, ${b.hours} hours, and ${b.minutes} minutes."
  15. }