Compare two Date

 
import java.util.Date;

public class Main {
  public static Date max(Date d1, Date d2) {
    if (d1 == null && d2 == null)
      return null;
    if (d1 == null)
      return d2;
    if (d2 == null)
      return d1;
    return (d1.after(d2)) ? d1 : d2;
  }
  
  public static Date min(Date d1, Date d2) {
    if (d1 == null && d2 == null)
      return null;
    if (d1 == null)
      return d2;
    if (d2 == null)
      return d1;
    return (d1.before(d2)) ? d1 : d2;
  }
}
  
Home 
  Java Book 
    Runnable examples  

Date Compare:
  1. Are two calendar objects represent the same local time.
  2. Are two dates or two calendars the same day
  3. Is a date the same day with another date
  4. Is a date after another date
  5. Is a date before another date
  6. Is date or calendar today's date
  7. Is a calendar or date after/before today or within a number of days in the future
  8. Compare two Date objects using compareTo
  9. Compares two dates are equals at day, month and year level, ignoring time
  10. Compare two times equals regardless of the date
  11. Compare two dates and times for equal
  12. Compare two Date