我在 Coldfusion 中使用 Java 对象,所以我的代码有点偏离。
我有一个看起来像这样的函数:
function getJODAOffset(sTimezone){
local.oDateTimeZone = createObject('java','org.joda.time.DateTimeZone');
local.oInstant = createObject('Java','org.joda.time.Instant');
local.oFormatter = createObject("Java",'org.joda.time.format.DateTimeFormat');
local.oFormatter = local.oFormatter.forPattern('ZZ');
local.tTime = local.oDateTimeZone.forID(arguments.sTimezone).getStandardOffset(local.oInstant); //sTimezone = 'Europe/London';
return local.oFormatter.withZone(local.oDateTimeZone.forID(arguments.sTimezone)).print(local.tTime);
}
当我期望“ +00:00 ”时,这给了我“ +01:00 ”的输出,我不知道为什么。