Android Calendar Compare isSameDay(Calendar calSource, Calendar calDesti)

Here you can find the source of isSameDay(Calendar calSource, Calendar calDesti)

Description

is Same Day

Declaration

public static boolean isSameDay(Calendar calSource, Calendar calDesti) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static boolean isSameDay(Date dateSource, Date dateDesti) {
        if (dateSource == null || dateDesti == null) {
            throw new IllegalArgumentException("The date must not be null");
        }/*from w ww . j  a  v  a  2s.c om*/
        Calendar objCalendarSource = Calendar.getInstance();
        objCalendarSource.setTime(dateSource);
        Calendar objCalendarDesti = Calendar.getInstance();
        objCalendarDesti.setTime(dateDesti);
        return isSameDay(objCalendarSource, objCalendarDesti);
    }

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

Related

  1. compareCurrentDate(String currentDate)
  2. isAfterRollingTime(Calendar date)
  3. isAfterRollingTimeOut(Calendar date)
  4. isBeforeRollingEndTime(Calendar date)
  5. isBeforeRollingTime(Calendar date)
  6. isSameInstant(Calendar cal1, Calendar cal2)
  7. isSameLocalTime(Calendar calSource, Calendar calDesti)
  8. compare(Calendar d1, Calendar d2)
  9. getDateDelta(int delta, String dateFormat)