Groovy web console

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

Default Timezone

Published 5 months ago by seeyoung with tags timezone
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.text.SimpleDateFormat
 
println "default TimeZone = "+TimeZone.default
 
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Date date = new Date()
 
println "default timezone(UTC) new Date() = $date"
 
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
isoFormat.setTimeZone(TimeZone.getTimeZone("Asia/Seoul"));
println "SimpleDateFormat with Asia/Seoul = "+isoFormat.format(date)
 
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
println "default timezone with 'Asia/Seoul' = $date"