Java Date Equal equalsWoTime(final Date date1, final Date date2)

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

Description

equals Wo Time

License

Open Source License

Declaration

public static boolean equalsWoTime(final Date date1, final Date date2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static boolean equalsWoTime(final Date date1, final Date date2) {
        return getZeroTimeDate(date1).equals(getZeroTimeDate(date2));
    }//  ww w.j av  a2s.c  om

    public static Date getZeroTimeDate(final Date date) {
        final Calendar calendar = Calendar.getInstance();

        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        return calendar.getTime();
    }
}

Related

  1. equal(Date date, Date other)
  2. equalDateByDay(Date date1, Date date2)
  3. equalDates(Date first, Date second)
  4. equalsIgnoreTime(final Date d1, final Date d2)
  5. equalsToDate(Date date1, Date date2, boolean checkTime)
  6. firstLessOrEqualSecond(Date firstDate, Date secondDate)
  7. hourEqual(Date date1, Date date2)
  8. isEqual(Date date1, Date date2)
  9. isEqualByDay(Date date1, Date date2)