Here you can find the source of isEqual(Calendar calendar, Date date)
Parameter | Description |
---|---|
calendar | The Calendar object. |
date | The date object. |
public static boolean isEqual(Calendar calendar, Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**// w ww. jav a 2 s .c om * Returns true if the month day and year for the calendar and date object are the same. * @param calendar The Calendar object. * @param date The date object. */ public static boolean isEqual(Calendar calendar, Date date) { if (calendar == null && date == null) { return true; } if (calendar == null || date == null) { return false; } Calendar calendarValueForDateVariable = Calendar.getInstance(); calendarValueForDateVariable.setTime(date); return calendarValueForDateVariable.get(Calendar.MONTH) == calendar.get(Calendar.MONTH) && calendarValueForDateVariable.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && calendarValueForDateVariable.get(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH); } }