Class InstantComparator

java.lang.Object
org.eclipse.jgit.treewalk.InstantComparator
All Implemented Interfaces:
Comparator<Instant>

class InstantComparator extends Object implements Comparator<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.
  • Constructor Details

    • InstantComparator

      InstantComparator()
  • Method Details

    • compare

      public int compare(Instant a, Instant b)
      Specified by:
      compare in interface Comparator<Instant>
    • compare

      public int compare(Instant a, 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