我想用 Joda 时间将当前时间转换为特定时区的时间。
有没有办法将 DateTime time = new DateTime()
转换为特定时区,或者获取 time.getZone()
之间的小时数差异和另一个 DateTimeZone
然后执行 time.minusHours
或 time.plusHours
?
最佳答案
I want to convert the current time to the time in a specific timezone with Joda time.
您不是很清楚您是否已经得到当前时间。如果你已经得到它,你可以使用 withZone
:
DateTime zoned = original.withZone(zone);
如果您只是获取当前时间,请使用 appropriate constructor :
DateTime zoned = new DateTime(zone);
或使用 DateTime.now
:
DateTime zoned = DateTime.now(zone);
关于java - Joda Time - 不同时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11629936/