Java Date Compare compareDate(Date date1, Date date2)

Here you can find the source of compareDate(Date date1, Date date2)

Description

compare Date

License

Open Source License

Declaration

public static int compareDate(Date date1, Date date2) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static int compareDate(Date date1, Date date2) {
        if (date1 == null || date2 == null)
            return -1;

        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();

        cal1.setTime(date1);/*from   ww  w. java 2 s .c o  m*/
        cal2.setTime(date2);

        return cal1.compareTo(cal2);
    }
}

Related

  1. compareDate(Date date1)
  2. compareDate(Date date1, Date date2)
  3. compareDate(Date DATE1, Date DATE2)
  4. compareDate(Date date1, Date date2)
  5. compareDate(Date date1, Date date2)
  6. compareDate(Date date1, Date date2)
  7. compareDate(Date date1, Date date2)
  8. compareDate(Date date1, Date date2, String pattern)
  9. compareDate(Date first, Date second)