Guest User

Untitled

a guest
Oct 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import groovy.time.TimeCategory
  2.  
  3. random = new Random()
  4.  
  5. Date randomDate(Range<Date> range) {
  6. def res = range.from + random.nextInt(range.to - range.from + 1)
  7. use( TimeCategory ) {
  8. res = res + random.nextInt(24).hours + random.nextInt(60).minutes + random.nextInt(60).seconds
  9. }
  10. res
  11. }
  12.  
  13.  
  14. def start = Date.parse('yyyy-MM-dd mm:ss', '2015-01-01 00:00')
  15. def end = Date.parse('yyyy-MM-dd mm:ss', '2017-12-31 23:59')
  16. println randomDate(start..end)
Add Comment
Please, Sign In to add comment