I want to convert the current time to the time in a specific timezone with Joda time.
Is there a way to convert DateTime time = new DateTime()
to a specific timezone, or perhaps to get the number of hours difference between time.getZone()
and another DateTimeZone
to then do time.minusHours
or time.plusHours
?
It's not really clear whether you've already got the current time or not. If you've already got it, you can use
withZone
:If you're just fetching the current time, use the appropriate constructor:
or use
DateTime.now
:check out DateTimeZone & Interval at
http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTimeZone.html & http://joda-time.sourceforge.net/apidocs/org/joda/time/Interval.html
Interval: