【问题标题】:Joda DateTime Offset IssuesJoda DateTime 偏移问题
【发布时间】:2020-07-08 12:11:02
【问题描述】:

我正在尝试获取正确的偏移量,以便可以使用它来执行一些计算,但遇到了问题。当我知道此时偏移量应该是 5 时,我总是得到零。如果有人可以帮助查明问题,那将有很大帮助。

DateTimeZone dateTz = DateTimeZone.forID('America/Chicago')
DateTime now = new DateTime(dateTz)
DateTimeZone tz = DateTimeZone.forID("UTC");
long offsetInMilliseconds = tz.getOffset(now.getMillis())

当它应该是正确的偏移量时,变量 offsetInMilliseconds 将始终为 0。

【问题讨论】:

    标签: jodatime


    【解决方案1】:

    好吧,看来我需要使用 getOffsetFromLocal 而不是 getOffset,谜团解开了。

    【讨论】:

      猜你喜欢
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多