Here you can find the source of isSameWeek(Date date)
public static boolean isSameWeek(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static boolean isSameWeek(Date date) { Calendar beginningOfTheWeek = Calendar.getInstance(); beginningOfTheWeek.set(Calendar.DAY_OF_WEEK, beginningOfTheWeek.getFirstDayOfWeek()); beginningOfTheWeek.set(Calendar.HOUR, 0); beginningOfTheWeek.set(Calendar.MINUTE, 0); Calendar endOfTheWeek = Calendar.getInstance(); endOfTheWeek.set(Calendar.DAY_OF_WEEK, endOfTheWeek.getFirstDayOfWeek()); endOfTheWeek.add(Calendar.DAY_OF_WEEK, 7); endOfTheWeek.set(Calendar.HOUR, 23); endOfTheWeek.set(Calendar.MINUTE, 59); return date.after(beginningOfTheWeek.getTime()) && date.before(endOfTheWeek.getTime()); }//w w w .j a v a 2s.c o m }