語言

ZonedDateTime.WithFixedOffsetZone 方法

定義

回傳一份將區域 ID 設為偏移的日期時間副本。

[Android.Runtime.Register("withFixedOffsetZone", "()Ljava/time/ZonedDateTime;", "", ApiSince=26)]
public Java.Time.ZonedDateTime? WithFixedOffsetZone();
[<Android.Runtime.Register("withFixedOffsetZone", "()Ljava/time/ZonedDateTime;", "", ApiSince=26)>]
member this.WithFixedOffsetZone : unit -> Java.Time.ZonedDateTime

傳回

一個區域 ID 設為偏移量的 ZonedDateTime,而非 null

屬性

備註

回傳一份將區域 ID 設為偏移的日期時間副本。 此時回傳一個區域日期時間,區域 ID 與 getOffset() 相同。 當地的日期時間、偏移量和結果的瞬間將與該日期時間相同。 將日期時間設定為固定的單一偏移量,意味著未來的計算,如加法或減法,因時區規則而不會有複雜的邊界。 這在傳送分區日期時間跨網路時也可能很有用,因為大多數協定(如 ISO-8601)只處理偏移量,不處理區域 ID。 這相當於 ZonedDateTime.of(zdt.toLocalDateTime(), zdt.getOffset())。

Java 參考 java.time.ZonedDateTime.withFixedOffsetZone。

適用於