Groovy web console

subscribe to the feed Subscribe
to this
site
compare dates (via #groovywebconsole)
tweet this snippet Tweet
this
script

compare dates

Published 9 months ago by nmrao with tags compare date
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def dateStr1 = 'Tue Feb 28 16:23:20 2017 -0600'
def dateStr2 = 'Tue Feb 28 17:24:06 EST 2017'
def pattern1 = "EEE MMM dd HH:mm:ss yyyy Z"
def pattern2 = "EEE MMM dd HH:mm:ss z yyyy"
def date1 = new Date().parse(pattern1, dateStr1)
def date2 = new Date().parse(pattern2, dateStr2)
assert date1 > date2, 'Execute date is earlier'