ZonedDateTime 类

定义

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

[Android.Runtime.Register("java/time/ZonedDateTime", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class ZonedDateTime : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Time.Chrono.IChronoZonedDateTime
[<Android.Runtime.Register("java/time/ZonedDateTime", ApiSince=26, DoNotGenerateAcw=true)>]
type ZonedDateTime = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IChronoZonedDateTime
    interface IComparable
    interface ITemporal
    interface ITemporalAccessor
继承
ZonedDateTime
属性
实现

注解

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

ZonedDateTime 是具有时区的日期时间的不可变表示形式。 此类将所有日期和时间字段存储到纳秒精度和时区,以及用于处理不明确的本地日期时间的区域偏移量。 例如,值“2007 年 10 月 2 日 13:45.30.123456789 +02:00”可以存储在一个 ZonedDateTime区域中。

此类处理从本地时间行 LocalDateTime 到即时时间线的 Instant转换。 两个时间线之间的差异是 UTC/格林威治的偏移量,由 a ZoneOffset表示。

在两个时间线之间进行转换涉及使用从中ZoneId访问的ZoneRules rules偏移量计算偏移量。 获取即时偏移量非常简单,因为每个即时的偏移量正好有一个有效偏移量。 相比之下,获取本地日期时间的偏移量并不简单。 有三种情况: <ul><li>Normal,一个有效偏移量。 对于大部分年份,正常情况适用,其中本地日期时间存在单个有效偏移量。</li li><>Gap,具有零有效偏移量。 这是当时钟跳跃通常是由于春夏令时从“冬天”更改为“夏天”。 在间隙中,存在没有有效偏移量的本地日期时间值。</li li><>Overlap,具有两个有效偏移量。 这是当时钟被设置通常由于秋季夏令时从“夏季”更改为“冬季”。 在重叠中,有两个有效偏移量的本地日期时间值。</li></ul>

通过获取偏移量,从本地日期时间直接或隐式转换为即时的任何方法都有可能很复杂。

对于 Gap,一般策略是,如果本地日期时间在 Gap 中间下降,则生成的区域日期时间将按 Gap 的长度向前移动本地日期时间,从而导致日期时间在以后的偏移量(通常是“夏季”时间)。

对于重叠,一般策略是,如果本地日期时间处于重叠中间,则保留以前的偏移量。 如果没有以前的偏移量,或者以前的偏移量无效,则使用以前的偏移量,通常是“summer”时间。 另外两种方法 #withEarlierOffsetAtOverlap() ,以及 #withLaterOffsetAtOverlap()帮助管理重叠情况。

在设计方面,此类应主要被视为 a LocalDateTime 和 a ZoneId的组合。 ZoneOffset这是一个至关重要但次要的信息片段,用于确保类表示即时,尤其是在夏令时重叠期间。

已在 1.8 中添加。

适用于 . 的 java.time.ZonedDateTimeJava 文档

本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。

属性

名称 说明
Class

返回此 Object的运行时类。

(继承自 Object)
DayOfMonth

获取月份日期字段。

DayOfWeek

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

DayOfYear

获取年份日期字段。

Handle

基础 Android 实例的句柄。

(继承自 Object)
Hour

获取“天小时”字段。

JniIdentityHashCode

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
JniPeerMembers

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Minute

获取小时分钟字段。

Month

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MonthValue

获取从 1 到 12 的年月字段。

Nano

获取 nano-of-second 字段。

Offset

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PeerReference

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
Second

获取分钟秒字段。

ThresholdClass

此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。

(继承自 Object)
ThresholdType

此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。

(继承自 Object)
Year

获取年份字段。

Zone

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

方法

名称 说明
Clone()

创建并返回此对象的副本。

(继承自 Object)
CompareTo(Object)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Dispose()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
Dispose(Boolean)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
Equals(Object)

指示其他对象是否“等于”此对象。

(继承自 Object)
Format(DateTimeFormatter)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

From(ITemporalAccessor)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Get(ITemporalField)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

GetHashCode()

返回对象的哈希代码值。

(继承自 Object)
GetLong(ITemporalField)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IsSupported(ITemporalField)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IsSupported(ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

JavaFinalize()

当垃圾回收确定不再引用该对象时,由对象上的垃圾回收器调用。

(继承自 Object)
Minus(Int64, ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Minus(ITemporalAmount)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusDays(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusHours(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusMinutes(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusMonths(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusNanos(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusSeconds(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusWeeks(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

MinusYears(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Notify()

唤醒正在等待此对象的监视器的单个线程。

(继承自 Object)
NotifyAll()

唤醒正在等待此对象的监视器的所有线程。

(继承自 Object)
Now()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Now(Clock)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Now(ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Of(Int32, Int32, Int32, Int32, Int32, Int32, Int32, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Of(LocalDate, LocalTime, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Of(LocalDateTime, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

OfInstant(Instant, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

OfInstant(LocalDateTime, ZoneOffset, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

OfLocal(LocalDateTime, ZoneId, ZoneOffset)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

OfStrict(LocalDateTime, ZoneOffset, ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Parse(ICharSequence, DateTimeFormatter)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Parse(ICharSequence)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Parse(String, DateTimeFormatter)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Parse(String)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Plus(Int64, ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Plus(ITemporalAmount)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusDays(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusHours(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusMinutes(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusMonths(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusNanos(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusSeconds(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusWeeks(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

PlusYears(Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Query(ITemporalQuery)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Range(ITemporalField)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

SetHandle(IntPtr, JniHandleOwnership)

设置 Handle 属性。

(继承自 Object)
ToArray<T>()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
ToLocalDate()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

ToLocalDateTime()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

ToLocalTime()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

ToOffsetDateTime()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

ToString()

返回对象的字符串表示形式。

(继承自 Object)
TruncatedTo(ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

UnregisterFromRuntime()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
Until(ITemporal, ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

Wait()

使当前线程等待,直到唤醒它,通常是通过 em 通知/em< 或 >em<interrupted>/em<。><>

(继承自 Object)
Wait(Int64, Int32)

使当前线程等待直到唤醒,通常是通过 <em>通知</em> 或 <em interrupted>/em<>,或直到经过一定数量的实时。

(继承自 Object)
Wait(Int64)

使当前线程等待直到唤醒,通常是通过 <em>通知</em> 或 <em interrupted>/em<>,或直到经过一定数量的实时。

(继承自 Object)
With(ITemporalAdjuster)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

With(ITemporalField, Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithDayOfMonth(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithDayOfYear(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithEarlierOffsetAtOverlap()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithFixedOffsetZone()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithHour(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithLaterOffsetAtOverlap()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithMinute(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithMonth(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithNano(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithSecond(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithYear(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithZoneSameInstant(ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

WithZoneSameLocal(ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

显式接口实现

名称 说明
IChronoZonedDateTime.Plus(Int64, ITemporalUnit)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.ToLocalDateTime()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.With(ITemporalField, Int64)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.WithEarlierOffsetAtOverlap()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.WithLaterOffsetAtOverlap()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.WithZoneSameInstant(ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IChronoZonedDateTime.WithZoneSameLocal(ZoneId)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

IJavaPeerable.Disposed()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.DisposeUnlessReferenced()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.Finalized()

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.JniManagedPeerState

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

(继承自 Object)

扩展方法

名称 说明
GetJniTypeName(IJavaPeerable)

获取实例 self类型的 JNI 名称。

JavaAs<TResult>(IJavaPeerable)

尝试强制self键入TResult,检查强制是否在Java端有效。

JavaCast<TResult>(IJavaObject)

执行 Android 运行时检查的类型转换。

JavaCast<TResult>(IJavaObject)

ISO-8601 日历系统中具有时区的日期时间,例如 2007-12-03T10:15:30+01:00 Europe/Paris

TryJavaCast<TResult>(IJavaPeerable, TResult)

尝试强制self键入TResult,检查强制是否在Java端有效。

适用于