本文整理汇总了Java中java.time.jdk8.Jdk7Methods.Long_compare方法的典型用法代码示例。如果您正苦于以下问题:Java Jdk7Methods.Long_compare方法的具体用法?Java Jdk7Methods.Long_compare怎么用?Java Jdk7Methods.Long_compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.jdk8.Jdk7Methods
的用法示例。
在下文中一共展示了Jdk7Methods.Long_compare方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
/**
* Compares this duration to the specified {@code Duration}.
* <p>
* The comparison is based on the total length of the durations. It is "consistent with equals", as defined
* by {@link Comparable}.
*
* @param otherDuration the other duration to compare to, not null
* @return the comparator value, negative if less, positive if greater
*/
@Override
public int compareTo(Duration otherDuration) {
int cmp = Jdk7Methods.Long_compare(this.seconds, otherDuration.seconds);
if (cmp != 0) {
return cmp;
}
return this.nanos - otherDuration.nanos;
}
示例2: compare
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
@Override
public int compare(ChronoZonedDateTime<?> datetime1, ChronoZonedDateTime<?> datetime2) {
int cmp = Jdk7Methods.Long_compare(datetime1.toEpochSecond(), datetime2.toEpochSecond());
if (cmp == 0) {
cmp = Jdk7Methods.Long_compare(datetime1.getTime().toNanoOfDay(), datetime2.getTime().toNanoOfDay());
}
return cmp;
}
示例3: compare
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
@Override
public int compare(ChronoLocalDateTime<?> datetime1, ChronoLocalDateTime<?> datetime2) {
int cmp = Jdk7Methods.Long_compare(datetime1.getDate().toEpochDay(), datetime2.getDate().toEpochDay());
if (cmp == 0) {
cmp = Jdk7Methods.Long_compare(datetime1.getTime().toNanoOfDay(), datetime2.getTime().toNanoOfDay());
}
return cmp;
}
示例4: compareTo
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
/**
* Compares this {@code OffsetDateTime} to another date-time.
* <p>
* The comparison is based on the instant then on the local date-time. It is "consistent with equals", as
* defined by {@link Comparable}.
* <p>
* For example, the following is the comparator order:
* <ol>
* <li>{@code 2008-12-03T10:30+01:00}</li>
* <li>{@code 2008-12-03T11:00+01:00}</li>
* <li>{@code 2008-12-03T12:00+02:00}</li>
* <li>{@code 2008-12-03T11:30+01:00}</li>
* <li>{@code 2008-12-03T12:00+01:00}</li>
* <li>{@code 2008-12-03T12:30+01:00}</li>
* </ol>
* Values #2 and #3 represent the same instant on the time-line. When two values represent the same instant,
* the local date-time is compared to distinguish them. This step is needed to make the ordering consistent
* with {@code equals()}.
*
* @param other the other date-time to compare to, not null
* @return the comparator value, negative if less, positive if greater
*/
@Override
public int compareTo(OffsetDateTime other) {
if (getOffset().equals(other.getOffset())) {
return getDateTime().compareTo(other.getDateTime());
}
int cmp = Jdk7Methods.Long_compare(toEpochSecond(), other.toEpochSecond());
if (cmp == 0) {
cmp = getTime().getNano() - other.getTime().getNano();
if (cmp == 0) {
cmp = getDateTime().compareTo(other.getDateTime());
}
}
return cmp;
}
示例5: compare
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
@Override
public int compare(DateTimeAccessor dateTime1, DateTimeAccessor dateTime2) {
return Jdk7Methods.Long_compare(dateTime1.getLong(this), dateTime2.getLong(this));
}
示例6: compare
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
@Override
public int compare(ChronoLocalDate<?> date1, ChronoLocalDate<?> date2) {
return Jdk7Methods.Long_compare(date1.toEpochDay(), date2.toEpochDay());
}
示例7: compareTo
import java.time.jdk8.Jdk7Methods; //导入方法依赖的package包/类
/**
* Compares this instant to the specified instant.
* <p>
* The comparison is based on the time-line position of the instants. It is "consistent with equals", as
* defined by {@link Comparable}.
*
* @param otherInstant the other instant to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @throws NullPointerException if otherInstant is null
*/
@Override
public int compareTo(Instant otherInstant) {
int cmp = Jdk7Methods.Long_compare(this.seconds, otherInstant.seconds);
if (cmp != 0) {
return cmp;
}
return this.nanos - otherInstant.nanos;
}