Here you can find the source of isSameDay(Calendar cal1, Calendar cal2)
Parameter | Description |
---|---|
cal1 | Calendar to compare to cal2 |
cal2 | Calendar to compare to cal1 |
public static boolean isSameDay(Calendar cal1, Calendar cal2)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { /**/*from w ww . j a v a 2 s. c o m*/ * Check to see if two Calendars are on the same Day, by comparing * the year, month and date * @param cal1 Calendar to compare to cal2 * @param cal2 Calendar to compare to cal1 * @return true if both Calendars are on the same day */ public static boolean isSameDay(Calendar cal1, Calendar cal2) { int year1 = cal1.get(Calendar.YEAR); int year2 = cal2.get(Calendar.YEAR); if (year1 == year2) { int month1 = cal1.get(Calendar.MONTH); int month2 = cal2.get(Calendar.MONTH); if (month1 == month2) { int day1 = cal1.get(Calendar.DAY_OF_MONTH); int day2 = cal2.get(Calendar.DAY_OF_MONTH); if (day1 == day2) { return true; } } } return false; } }