ChronoField.GetFrom(ITemporalAccessor) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從指定的時間物件取得此欄位的值。
[Android.Runtime.Register("getFrom", "(Ljava/time/temporal/TemporalAccessor;)J", "", ApiSince=26)]
public long GetFrom(Java.Time.Temporal.ITemporalAccessor? temporal);
[<Android.Runtime.Register("getFrom", "(Ljava/time/temporal/TemporalAccessor;)J", "", ApiSince=26)>]
abstract member GetFrom : Java.Time.Temporal.ITemporalAccessor -> int64
override this.GetFrom : Java.Time.Temporal.ITemporalAccessor -> int64
參數
- temporal
- ITemporalAccessor
查詢的時空物件,而非 null
傳回
此欄位的值,而非零
實作
- 屬性
備註
從指定的時間物件取得此欄位的值。 此時查詢時間物件以獲取該欄位的值。 使用此方法有兩種等效方式。 第一種是直接引用此方法。
// these two lines are equivalent, but the second approach is recommended
temporal = thisField.getFrom(temporal);
temporal = temporal.getLong(thisField);
建議使用第二種方法,getLong(TemporalField),因為在程式碼中閱讀起來更清晰。 實作應使用ChronoField中可用的欄位來執行任何查詢或計算。 若欄位不被支援,必須拋出 UnsupportedTemporalTypeException。
Java 參考 java.time.temporal.ChronoField.getFrom。