Here you can find the source of sameDate(Date date1, Date date2)
public static boolean sameDate(Date date1, Date date2)
//package com.java2s; /******************************************************************************* * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://ww w . j a v a 2 s.c o m * emil.crumhorn@gmail.com - initial API and implementation *******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { public static boolean sameDate(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal2.setTime(date2); return sameDate(cal1, cal2); } public static boolean sameDate(Calendar cal1, Calendar cal2) { if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)) { if (cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)) { return true; } } return false; } }