Java tutorial
//package com.java2s; //License from project: Open Source License import java.sql.Date; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /** * Method to see if a date has already passed. the time of the day has no * relevance. * * @param theDate * the date to see if it has passed * @return true if the date has passed */ public static boolean dateHasPassed(Date theDate) { // Get a calendar with the events start time GregorianCalendar theCalendar = new GregorianCalendar(); theCalendar.setTime(theDate); // Get a calendar with current system time to compare with Calendar systemCalendar = Calendar.getInstance(); // If it should return true only if today and not before use == instead // of >= return systemCalendar.get(Calendar.YEAR) > theCalendar.get(Calendar.YEAR) || (systemCalendar.get(Calendar.YEAR) == theCalendar.get(Calendar.YEAR) && systemCalendar.get(Calendar.DAY_OF_YEAR) > theCalendar.get(Calendar.DAY_OF_YEAR)); } }