Java Calendar Compare isEquals(Calendar sourceDate, Calendar compareDate)

Here you can find the source of isEquals(Calendar sourceDate, Calendar compareDate)

Description

is Equals

License

Open Source License

Declaration

public static boolean isEquals(Calendar sourceDate, Calendar compareDate) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static boolean isEquals(Calendar sourceDate, Calendar compareDate) {

        boolean check = false;

        if ((sourceDate.get(Calendar.DATE) == compareDate.get(Calendar.DATE))
                && (sourceDate.get(Calendar.MONTH) == compareDate.get(Calendar.MONTH))
                && (sourceDate.get(Calendar.YEAR) == compareDate.get(Calendar.YEAR))) {
            check = true;//from   w  w  w .  j av a2  s  . c om
        }
        return check;
    }

    public static boolean isEquals(Date sourceDate, Date compareDate) {
        return isEquals(getCalendar(sourceDate), getCalendar(compareDate));
    }

    public static Calendar getCalendar(Date date) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar;
    }
}

Related

  1. compareDateTime(final Calendar firstCal, final Calendar secondCal)
  2. compareDay(Calendar calendar, Calendar calendar1)
  3. compareSameDay(Calendar first, Calendar second)
  4. compareTime(final Calendar firstCal, final Calendar secondCal)
  5. isEqual(Calendar calendar, Date date)
  6. isSameDate(Calendar d1, Calendar d2)
  7. isSameDate(java.util.Calendar date1, java.util.Calendar date2)
  8. isSameInstant(Calendar cal1, Calendar cal2)
  9. isSameInstant(Calendar cal1, Calendar cal2)