Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import groovy.time.TimeCategory
- random = new Random()
- Date randomDate(Range<Date> range) {
- def res = range.from + random.nextInt(range.to - range.from + 1)
- use( TimeCategory ) {
- res = res + random.nextInt(24).hours + random.nextInt(60).minutes + random.nextInt(60).seconds
- }
- res
- }
- def start = Date.parse('yyyy-MM-dd mm:ss', '2015-01-01 00:00')
- def end = Date.parse('yyyy-MM-dd mm:ss', '2017-12-31 23:59')
- println randomDate(start..end)
Add Comment
Please, Sign In to add comment