Class DateComparator<T>

  • Type Parameters:
    T - With the main implementation, T must be a sub class of java.util.Date
    All Implemented Interfaces:
    java.util.Comparator<T>
    Direct Known Subclasses:
    DateDescendingComparator

    public class DateComparator<T>
    extends java.lang.Object
    implements java.util.Comparator<T>
    This class implements a Comparator which compares two Date objects in the ascending order.
    Version:
    $Revision: 107554 $
    Author:
    Olivier Jaquemet
    See Also:
    Comparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String REVISION  
    • Constructor Summary

      Constructors 
      Constructor Description
      DateComparator()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(T o1, T o2)  
      static int compareDate​(java.util.Date d1, java.util.Date d2)
      Compares two Dates in ascending order.
      • 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

      • DateComparator

        public DateComparator()
    • Method Detail

      • compare

        public int compare​(T o1,
                           T o2)
        Specified by:
        compare in interface java.util.Comparator<T>
      • compareDate

        public static int compareDate​(java.util.Date d1,
                                      java.util.Date d2)
        Compares two Dates in ascending order.
        Parameters:
        d1 - the first date
        d2 - the second date
        Returns:
        -1, 0 or 1 if d1 is lower than, equals or greater than d2