Android Date Compare isSameDay(Date dateSource, Date dateDesti)

Here you can find the source of isSameDay(Date dateSource, Date dateDesti)

Description

is Same Day

Declaration

public static boolean isSameDay(Date dateSource, Date dateDesti) 

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");
        }//w  ww .  j a  va2  s.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. compareDate(Date date1, Date date2)
  2. compareDate(Date date1, Date date2, int what)
  3. compareDate(String date1, String date2, int what)
  4. dateAfterDate(Date date, long days)
  5. dateBeforeDate(Date date, long days)
  6. isSameInstant(Date date1, Date date2)
  7. needsMidnightCountdown()
  8. dateDiffer(Date date1, Date date2)
  9. compare(Date date1, Date date2)