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;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static int compareDate(Date date1, Date date2) {

        long due = date1.getTime() + 0 * 24 * 60 * 60 * 1000;
        long due2 = date2.getTime() + 0 * 24 * 60 * 60 * 1000;
        if (due == due2) {
            return 0;
        } else if (due > due2) {
            return 1;
        } else/*from  www . j a v  a  2s .  c om*/
            return -1;
    }

    public static String getTime(Date dt, String format) {
        SimpleDateFormat st = new SimpleDateFormat(format);
        return st.format(dt);
    }
}

Related

  1. CompareDate(Date date, Date otherdate)
  2. compareDate(Date date1)
  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)
  9. compareDate(Date date1, Date date2, String pattern)