Sdílet prostřednictvím


ITemporalField.GetFrom(ITemporalAccessor) Method

Definition

Gets the value of this field from the specified temporal object.

[Android.Runtime.Register("getFrom", "(Ljava/time/temporal/TemporalAccessor;)J", "GetGetFrom_Ljava_time_temporal_TemporalAccessor_Handler:Java.Time.Temporal.ITemporalFieldInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public long GetFrom (Java.Time.Temporal.ITemporalAccessor? temporal);
[<Android.Runtime.Register("getFrom", "(Ljava/time/temporal/TemporalAccessor;)J", "GetGetFrom_Ljava_time_temporal_TemporalAccessor_Handler:Java.Time.Temporal.ITemporalFieldInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member GetFrom : Java.Time.Temporal.ITemporalAccessor -> int64

Parameters

temporal
ITemporalAccessor

the temporal object to query, not null

Returns

the value of this field, not null

Attributes

Remarks

Gets the value of this field from the specified temporal object.

This queries the temporal object for the value of this field.

There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use TemporalAccessor#getLong(TemporalField) (or TemporalAccessor#get(TemporalField)):

// these two lines are equivalent, but the second approach is recommended
              temporal = thisField.getFrom(temporal);
              temporal = temporal.getLong(thisField);

It is recommended to use the second approach, getLong(TemporalField), as it is a lot clearer to read in code.

Implementations should perform any queries or calculations using the fields available in ChronoField. If the field is not supported an UnsupportedTemporalTypeException must be thrown.

Java documentation for java.time.temporal.TemporalField.getFrom(java.time.temporal.TemporalAccessor).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to