Here you can find the source of isSameDay(Calendar cal1, Calendar cal2)
Parameter | Description |
---|---|
cal1 | first calendar |
cal2 | second calendar |
public static boolean isSameDay(Calendar cal1, Calendar cal2)
//package com.java2s; import java.util.Calendar; public class Main { /**/* w w w . j ava 2s. c o m*/ * Determines if two calendar objects represent the same day. * @param cal1 first calendar * @param cal2 second calendar * @return true if month, day, and year are equal */ public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) return false; if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) return false; if (cal1.get(Calendar.MONTH) != cal2.get(Calendar.MONTH)) return false; if (cal1.get(Calendar.DAY_OF_MONTH) != cal2.get(Calendar.DAY_OF_MONTH)) return false; return true; } }