Date.TimezoneOffset 属性

定义

注意

deprecated

返回相对于 UTC 的本地时区的偏移量(以分钟为单位),该偏移量适合此 Date 对象表示的时间。

[System.Obsolete("deprecated")]
public virtual int TimezoneOffset { [Android.Runtime.Register("getTimezoneOffset", "()I", "GetGetTimezoneOffsetHandler")] get; }
[<System.Obsolete("deprecated")>]
[<get: Android.Runtime.Register("getTimezoneOffset", "()I", "GetGetTimezoneOffsetHandler")>]
member this.TimezoneOffset : int

属性值

当前时区的时区偏移量(以分钟为单位)。

属性

注解

返回相对于 UTC 的本地时区的偏移量(以分钟为单位),该偏移量适合此 Date 对象表示的时间。

例如,在马萨诸塞州,格林威治以西的五个时区: <块状>

new Date(96, 1, 14).getTimezoneOffset() returns 300

</blockquote> ,因为 1996 年 2 月 14 日,标准时间(东部标准时间)正在使用中,与 UTC 偏移 5 小时;但: <blockquote>

new Date(96, 5, 1).getTimezoneOffset() returns 240

</blockquote> ,因为 1996 年 6 月 1 日,夏令时(东部夏令时)正在使用,与 UTC 仅偏移四小时。

此方法生成的结果与计算结果相同: <blockquote>

(this.getTime() - UTC(this.getYear(),
                                  this.getMonth(),
                                  this.getDate(),
                                  this.getHours(),
                                  this.getMinutes(),
                                  this.getSeconds())) / (60 * 1000)

</blockquote>

此成员已弃用。 从 JDK 版本 1.1 起,替换为 -(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000).

Java文档java.util.Date.getTimezoneOffset()

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于