Here you can find the source of isSameDay(Date d1, Date d2)
public static boolean isSameDay(Date d1, Date d2)
//package com.java2s; /*/*from w w w. j a va 2 s .c o m*/ * Copyright 2011 http://pvoutput.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; import java.util.Date; public class Main { public static boolean isSameDay(Date d1, Date d2) { if (d1 != null && d2 != null) { Calendar c1 = Calendar.getInstance(); c1.setTime(d1); int n1 = c1.get(Calendar.DAY_OF_YEAR) + c1.get(Calendar.YEAR); c1.setTime(d2); int n2 = c1.get(Calendar.DAY_OF_YEAR) + c1.get(Calendar.YEAR); return n1 == n2; } return false; } }