Java Calendar Day isSameDay(Calendar cal1, Calendar cal2)

Here you can find the source of isSameDay(Calendar cal1, Calendar cal2)

Description

Determines if two calendar objects represent the same day.

License

Open Source License

Parameter

Parameter Description
cal1 first calendar
cal2 second calendar

Return

true if month, day, and year are equal

Declaration

public static boolean isSameDay(Calendar cal1, Calendar cal2) 

Method Source Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    /**/* w w  w  . j  ava  2s.  c  o  m*/
     * Determines if two calendar objects represent the same day.
     * @param cal1 first calendar
     * @param cal2 second calendar
     * @return true if month, day, and year are equal
     */
    public static boolean isSameDay(Calendar cal1, Calendar cal2) {
        if (cal1 == null || cal2 == null)
            return false;
        if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR))
            return false;
        if (cal1.get(Calendar.MONTH) != cal2.get(Calendar.MONTH))
            return false;
        if (cal1.get(Calendar.DAY_OF_MONTH) != cal2.get(Calendar.DAY_OF_MONTH))
            return false;
        return true;
    }
}

Related

  1. isEndOfDay(Calendar calendar)
  2. isHolyday(Calendar c)
  3. isRestDay(Calendar cal)
  4. isSameDay(Calendar c1, Calendar c2)
  5. isSameDay(Calendar cal1, Calendar cal2)
  6. isSameDay(Calendar cal1, Calendar cal2)
  7. isSameDay(Calendar cal1, Calendar cal2)
  8. isSameDay(Calendar cal1, Calendar cal2)
  9. isSameDay(Calendar cal1, Calendar cal2)