Java Date Compare compareDate(Date first, Date second)

Here you can find the source of compareDate(Date first, Date second)

Description

compare Date

License

Apache License

Declaration

public static int compareDate(Date first, Date second) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static int compareDate(Date first, Date second) {
        Calendar cf = Calendar.getInstance();
        cf.setTime(first);//from  w  w  w  .  j  av  a  2  s. co m
        Calendar cs = Calendar.getInstance();
        cs.setTime(second);
        if (cf.after(cs)) {
            return 1;
        }
        return cf.before(cs) ? -1 : 0;
    }
}

Related

  1. compareDate(Date DATE1, Date DATE2)
  2. compareDate(Date date1, Date date2)
  3. compareDate(Date date1, Date date2)
  4. compareDate(Date date1, Date date2)
  5. compareDate(Date date1, Date date2, String pattern)
  6. compareDate(Date sourceDate, Date targetDate)
  7. compareDate(Date start, Date end)
  8. compareDate(String begingDate, String endDate, String format)
  9. compareDate(String d1, String d2)