Here you can find the source of isBefore(Date date1, Date date2)
public static boolean isBefore(Date date1, Date date2)
//package com.java2s; /* This file is part of the MayDesk project. * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License.*/// ww w .j a v a2 s . co m import java.util.Calendar; import java.util.Date; public class Main { public static boolean isBefore(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); cal1.set(Calendar.HOUR, 0); cal1.set(Calendar.MINUTE, 0); cal1.set(Calendar.SECOND, 0); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal1.set(Calendar.HOUR, 0); cal1.set(Calendar.MINUTE, 0); cal1.set(Calendar.SECOND, 0); return cal1.before(cal2); } }