Java Calendar Day isSameDay(Calendar cal1, Calendar cal2)

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

Description

is Same Day

License

Apache License

Declaration

public static boolean isSameDay(Calendar cal1, Calendar cal2) 

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 isSameDay(Date date1, Date date2) {
        if (date1 == null || date2 == null) {
            throw new IllegalArgumentException("The date must not be null");
        }//from w  w  w.j a  va 2  s.c  o m
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);
        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);
        return isSameDay(cal1, cal2);
    }

    public static boolean isSameDay(Calendar cal1, Calendar cal2) {
        if (cal1 == null || cal2 == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
    }
}

Related

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