Java Date Equal nowInDateEquals(Date now, Date d1, Date d2)

Here you can find the source of nowInDateEquals(Date now, Date d1, Date d2)

Description

now In Date Equals

License

Apache License

Declaration

public static boolean nowInDateEquals(Date now, Date d1, Date d2) 

Method Source Code

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

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

public class Main {

    public static boolean nowInDateEquals(Date now, Date d1, Date d2) {
        if (compareDateEquals(d1, now)) {
            return true;
        } else if (compareDateEquals(d2, now)) {
            return true;
        } else if (now.after(d1) && now.before(d2)) {
            return true;
        }/*  w w  w.  j  a v a  2s  . c o m*/
        return false;
    }

    public static boolean compareDateEquals(Date d1, Date d2) {
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        c1.setTime(d1);
        c2.setTime(d2);

        int result = c1.compareTo(c2);
        if (result == 0)
            return true;
        else
            return false;
    }
}

Related

  1. isSameDate(Date date, Date date1)
  2. isSameDate(Date date1, Date date2)
  3. isSameDate(Date pathDate, Date now)
  4. isSameDate(long var0, long var2)
  5. monthEquals(Date current, Date compare)
  6. sameDate(Date date1, Date date2)
  7. sameDate(Date date1, Date date2)
  8. yearMonthsEqual(final Date firstDate, final Date secondDate)