@Override public long applyAsLong(OffsetDateTime dt) { return dt.toEpochSecond(); } },
@Override public int compare(OffsetDateTime datetime1, OffsetDateTime datetime2) { int cmp = Jdk8Methods.compareLongs(datetime1.toEpochSecond(), datetime2.toEpochSecond()); if (cmp == 0) { cmp = Jdk8Methods.compareLongs(datetime1.getNano(), datetime2.getNano()); } return cmp; } };
@Override public int compare(OffsetDateTime datetime1, OffsetDateTime datetime2) { int cmp = Jdk8Methods.compareLongs(datetime1.toEpochSecond(), datetime2.toEpochSecond()); if (cmp == 0) { cmp = Jdk8Methods.compareLongs(datetime1.getNano(), datetime2.getNano()); } return cmp; } };
/** * Checks if the instant of this date-time is equal to that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} * in that it only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ public boolean isEqual(OffsetDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); }
/** * Checks if the instant of this date-time is equal to that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} * in that it only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ public boolean isEqual(OffsetDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); }
/** * Checks if the instant of this date-time is after that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} in that it * only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if this is after the instant of the specified date-time */ public boolean isAfter(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec > otherEpochSec || (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano()); }
/** * Checks if the instant of this date-time is before that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} in that it * only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().isBefore(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if this is before the instant of the specified date-time */ public boolean isBefore(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec < otherEpochSec || (thisEpochSec == otherEpochSec && toLocalTime().getNano() < other.toLocalTime().getNano()); }
/** * Checks if the instant of this date-time is after that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} in that it * only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if this is after the instant of the specified date-time */ public boolean isAfter(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec > otherEpochSec || (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano()); }
/** * Checks if the instant of this date-time is before that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} in that it * only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().isBefore(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if this is before the instant of the specified date-time */ public boolean isBefore(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec < otherEpochSec || (thisEpochSec == otherEpochSec && toLocalTime().getNano() < other.toLocalTime().getNano()); }
if (field instanceof ChronoField) { switch ((ChronoField) field) { case INSTANT_SECONDS: return toEpochSecond(); case OFFSET_SECONDS: return getOffset().getTotalSeconds();
if (field instanceof ChronoField) { switch ((ChronoField) field) { case INSTANT_SECONDS: return toEpochSecond(); case OFFSET_SECONDS: return getOffset().getTotalSeconds();
return toLocalDateTime().compareTo(other.toLocalDateTime()); int cmp = Jdk8Methods.compareLongs(toEpochSecond(), other.toEpochSecond()); if (cmp == 0) { cmp = toLocalTime().getNano() - other.toLocalTime().getNano();
return toLocalDateTime().compareTo(other.toLocalDateTime()); int cmp = Jdk8Methods.compareLongs(toEpochSecond(), other.toEpochSecond()); if (cmp == 0) { cmp = toLocalTime().getNano() - other.toLocalTime().getNano();