Groovy web console

subscribe to the feed Subscribe
to this
site
convert date time to different time zone (via #groovywebconsole)
tweet this snippet Tweet
this
script

convert date time to different time zone

Published 6 months ago by nmrao with tags time
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def date = new Date() 
println date
def dtFormat = "yyyy-MM-dd'T'HH:mm:ssZ" 
def dt = date.format(dtFormat, TimeZone.getTimeZone('IST'))
println dt
assert dt instanceof String  
def newDate = Date.parse(dtFormat, dt) 
assert newDate instanceof Date
println newDate