Here you can find the source of getLastDayOfWeek(Date date)
public static Date getLastDayOfWeek(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getLastDayOfWeek(int year, int week) { week = week - 1;// www. j a va 2 s . c o m Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DATE, 1); Calendar cal = (Calendar) calendar.clone(); cal.add(Calendar.DATE, week * 7); return getLastDayOfWeek(cal.getTime()); } public static Date getLastDayOfWeek(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.SUNDAY); calendar.setTime(date); calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek() + 6); // Saturday return calendar.getTime(); } public static Date getFirstDayOfWeek(int year, int week) { week = week - 1; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DATE, 1); Calendar cal = (Calendar) calendar.clone(); cal.add(Calendar.DATE, week * 7); return getFirstDayOfWeek(cal.getTime()); } public static Date getFirstDayOfWeek(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.SUNDAY); calendar.setTime(date); calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); // Sunday return calendar.getTime(); } }