Here you can find the source of getSundayOfWeek(Date date)
public static Date getSundayOfWeek(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int FIRST_DAY_OF_WEEK = Calendar.MONDAY; public static Date getSundayOfWeek(Date date) { Calendar sunday = getCalendar(); sunday.setTime(date);//from www .j av a2 s. co m sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return sunday.getTime(); } public static Date getSundayOfWeek(int year, int weekOfYear) { Calendar sunday = getCalendar(); sunday.set(Calendar.YEAR, year); sunday.set(Calendar.WEEK_OF_YEAR, weekOfYear + 1); sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return sunday.getTime(); } private static Calendar getCalendar() { Calendar c = Calendar.getInstance(); c.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); return c; } }