Class InstantComparator

  • All Implemented Interfaces:
    java.util.Comparator<java.time.Instant>

    class InstantComparator
    extends java.lang.Object
    implements java.util.Comparator<java.time.Instant>
    Specialized comparator for Instants. If either timestamp has a zero fraction, compares only seconds. If either timestamp has no time fraction smaller than a millisecond, compares only milliseconds. If either timestamp has no fraction smaller than a microsecond, compares only microseconds.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.time.Instant a, java.time.Instant b)  
      int compare​(java.time.Instant a, java.time.Instant b, boolean forceSecondsOnly)
      Compares two Instants to the lower resolution of the two instants.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • InstantComparator

        InstantComparator()
    • Method Detail

      • compare

        public int compare​(java.time.Instant a,
                           java.time.Instant b)
        Specified by:
        compare in interface java.util.Comparator<java.time.Instant>
      • compare

        public int compare​(java.time.Instant a,
                           java.time.Instant b,
                           boolean forceSecondsOnly)
        Compares two Instants to the lower resolution of the two instants. See InstantComparator.
        Parameters:
        a - first Instant to compare
        b - second Instant to compare
        forceSecondsOnly - whether to omit all fraction comparison
        Returns:
        a value < 0 if a < b, a value > 0 if a > b, and 0 if a == b