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 check if a date is this week. Note that it checks if it is this * week and not 7 days ahead! * * @param theDate * the date to see if it is this week * @return true if it is this week */ public static boolean isThisWeek(Date theDate) { // Get a calendar with the events start time GregorianCalendar theCalendar = new GregorianCalendar(); theCalendar.setTime(theDate); // Get a calendar with current system time Calendar tmpDate = Calendar.getInstance(); return tmpDate.get(Calendar.YEAR) == theCalendar.get(Calendar.YEAR) && tmpDate.get(Calendar.WEEK_OF_YEAR) == theCalendar.get(Calendar.WEEK_OF_YEAR); } }