共用方式為


IChronoLocalDateTime.CompareTo(IChronoLocalDateTime) Method

Definition

Compares this date-time to another date-time, including the chronology.

[Android.Runtime.Register("compareTo", "(Ljava/time/chrono/ChronoLocalDateTime;)I", "GetCompareTo_Ljava_time_chrono_ChronoLocalDateTime_Handler:Java.Time.Chrono.IChronoLocalDateTime, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public virtual int CompareTo (Java.Time.Chrono.IChronoLocalDateTime? other);
[<Android.Runtime.Register("compareTo", "(Ljava/time/chrono/ChronoLocalDateTime;)I", "GetCompareTo_Ljava_time_chrono_ChronoLocalDateTime_Handler:Java.Time.Chrono.IChronoLocalDateTime, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member CompareTo : Java.Time.Chrono.IChronoLocalDateTime -> int
override this.CompareTo : Java.Time.Chrono.IChronoLocalDateTime -> int

Parameters

other
IChronoLocalDateTime

the other date-time to compare to, not null

Returns

the comparator value, negative if less, positive if greater

Attributes

Remarks

Compares this date-time to another date-time, including the chronology.

The comparison is based first on the underlying time-line date-time, then on the chronology. It is "consistent with equals", as defined by Comparable.

For example, the following is the comparator order: <ol> <li>2012-12-03T12:00 (ISO)</li> <li>2012-12-04T12:00 (ISO)</li> <li>2555-12-04T12:00 (ThaiBuddhist)</li> <li>2012-12-05T12:00 (ISO)</li> </ol> Values #2 and #3 represent the same date-time on the time-line. When two values represent the same date-time, the chronology ID is compared to distinguish them. This step is needed to make the ordering "consistent with equals".

If all the date-time objects being compared are in the same chronology, then the additional chronology stage is not required and only the local date-time is used.

This default implementation performs the comparison defined above.

Java documentation for java.time.chrono.ChronoLocalDateTime.compareTo(java.time.chrono.ChronoLocalDateTime<?>).

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