Here you can find the source of equalDates(Date first, Date second)
Date
objects match.
Parameter | Description |
---|---|
first | a parameter |
second | a parameter |
public static boolean equalDates(Date first, Date second)
//package com.java2s; //License from project: Creative Commons License import java.util.Calendar; import java.util.Date; public class Main { /**// w ww.j a va 2 s .c o m * Checks if year, month, date of two <code>Date</code> objects match. * @param first * @param second * @return */ public static boolean equalDates(Date first, Date second) { Calendar calFirst = Calendar.getInstance(); Calendar calSecond = Calendar.getInstance(); calFirst.setTime(first); calSecond.setTime(second); return calFirst.get(Calendar.YEAR) == calSecond.get(Calendar.YEAR) && calFirst.get(Calendar.MONTH) == calSecond.get(Calendar.MONTH) && calFirst.get(Calendar.DAY_OF_MONTH) == calSecond.get(Calendar.DAY_OF_MONTH); } }