Here you can find the source of isSameDate(Calendar d1, Calendar d2)
Parameter | Description |
---|---|
d1 | input date 1 |
d2 | input date 2 |
public static boolean isSameDate(Calendar d1, Calendar d2)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; public class Main { /**/*w w w .j a v a 2 s. c om*/ * Returns whether the input dates are on the same date. * * @param d1 * input date 1 * @param d2 * input date 2 * @return true if they are on the same date. */ public static boolean isSameDate(Calendar d1, Calendar d2) { return d1.get(Calendar.YEAR) == d2.get(Calendar.YEAR) && d1.get(Calendar.DAY_OF_YEAR) == d2.get(Calendar.DAY_OF_YEAR); } /** * Returns whether the input dates are on the same date. * * @param d1 * input date 1 * @param d2 * input date 2 * @return true if they are on the same date. */ public static boolean isSameDate(Date d1, Date d2) { Calendar c1 = Calendar.getInstance(); c1.setTime(d1); Calendar c2 = Calendar.getInstance(); c2.setTime(d2); return isSameDate(c1, c2); } }