Android Date Compare isSameDay(Date date1, Date date2)

Here you can find the source of isSameDay(Date date1, Date date2)

Description

is Same Day

License

Open Source License

Declaration

public static boolean isSameDay(Date date1, Date date2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static boolean isSameDay(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();

        cal1.setTime(date1);//from w w w.ja  v  a2s .c  o m
        cal2.setTime(date2);

        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2
                        .get(Calendar.DAY_OF_YEAR);
    }
}

Related

  1. compare(Date date1, Date date2)
  2. compare(String date0, String date1, String format)
  3. isDateTimeAfter(String startDate, String startTime, String endDate, String endTime)
  4. isDateNew(String YearMonthDayHourMinuteSeconds)
  5. isSameDay(Date d1, Date d2)