ZonedDateTime.OfInstant 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| OfInstant(Instant, ZoneId) |
從瞬間取得 ZonedDateTime 的實例。 |
| OfInstant(LocalDateTime, ZoneOffset, ZoneId) |
從結合當地日期時間與偏移量形成的瞬間,取得 ZonedDateTime 的實例。 |
OfInstant(Instant, ZoneId)
從瞬間取得 ZonedDateTime 的實例。
[Android.Runtime.Register("ofInstant", "(Ljava/time/Instant;Ljava/time/ZoneId;)Ljava/time/ZonedDateTime;", "", ApiSince=26)]
public static Java.Time.ZonedDateTime? OfInstant(Java.Time.Instant? instant, Java.Time.ZoneId? zone);
[<Android.Runtime.Register("ofInstant", "(Ljava/time/Instant;Ljava/time/ZoneId;)Ljava/time/ZonedDateTime;", "", ApiSince=26)>]
static member OfInstant : Java.Time.Instant * Java.Time.ZoneId -> Java.Time.ZonedDateTime
參數
- instant
- Instant
是從 Instant 來建立日期-時間,而非 null
- zone
- ZoneId
時區,不是零時區
傳回
分區日期時間,非零
- 屬性
備註
從瞬間取得 ZonedDateTime 的實例。 這會產生一個與指定時間相同的分區日期時間。 呼叫 ChronoZonedDateTime.toInstant() 會回傳與此處相同的即時訊息。 將瞬間轉換為分區日期時間很簡單,因為每個瞬間只有一個有效的偏移量。
Java 參考 java.time.ZonedDateTime.ofInstant。
適用於
OfInstant(LocalDateTime, ZoneOffset, ZoneId)
從結合當地日期時間與偏移量形成的瞬間,取得 ZonedDateTime 的實例。
[Android.Runtime.Register("ofInstant", "(Ljava/time/LocalDateTime;Ljava/time/ZoneOffset;Ljava/time/ZoneId;)Ljava/time/ZonedDateTime;", "", ApiSince=26)]
public static Java.Time.ZonedDateTime? OfInstant(Java.Time.LocalDateTime? localDateTime, Java.Time.ZoneOffset? offset, Java.Time.ZoneId? zone);
[<Android.Runtime.Register("ofInstant", "(Ljava/time/LocalDateTime;Ljava/time/ZoneOffset;Ljava/time/ZoneId;)Ljava/time/ZonedDateTime;", "", ApiSince=26)>]
static member OfInstant : Java.Time.LocalDateTime * Java.Time.ZoneOffset * Java.Time.ZoneId -> Java.Time.ZonedDateTime
參數
- localDateTime
- LocalDateTime
當地日期時間,非空時間
- offset
- ZoneOffset
區域偏移,不是零
- zone
- ZoneId
時區,不是零時區
傳回
分區日期時間,非零
- 屬性
備註
從結合當地日期時間與偏移量形成的瞬間,取得 ZonedDateTime 的實例。 此方法透過結合 LocalDateTime 與 ZoneOffset 來建立分區日期時間。 此組合唯一指定一個無歧義的瞬間。 將瞬間轉換為分區日期時間很簡單,因為每個瞬間只有一個有效的偏移量。 若有效偏移與指定偏移不同,則分區日期時間與偏移量將與指定不同。 若使用的 ZoneID 是 ZoneOffset,此方法等同於 of(LocalDateTime, ZoneId)。
Java 參考 java.time.ZonedDateTime.ofInstant。