Date Time Conversion based on the TimeZone Java/Groovy
问题 I am in MST and I want my Date in PST. I set the timeZone that I want. Now if i do c.getTime() I always get my server time. Instead I want Pacific Date time. Please help How to get the date time Object in the specified timezone. Calendar c= Calendar.getInstance(); TimeZone timezone= TimeZone.getTimeZone("PST"); c.setTimeZone(timezone) 回答1: Or, use JodaTime @Grab( 'joda-time:joda-time:2.3' ) import org.joda.time.* def now = new DateTime() println now.withZone( DateTimeZone.forTimeZone(