Here you can find the source of isSameWeekDates(Date date1, Date date2)
public static boolean isSameWeekDates(Date date1, Date date2)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static boolean isSameWeekDates(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1);//from w w w. j a v a2 s .c om cal2.setTime(date2); int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR); if (0 == subYear) { if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true; } else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) { if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true; } else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) { if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true; } return false; } }