Here you can find the source of getWeekEnd(Date date, int w)
public static Date getWeekEnd(Date date, int w)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static Date getWeekEnd(Date date, int w) { Calendar c = Calendar.getInstance(); c.setTime(date);/* w ww . j a va2 s .co m*/ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1; if (dayOfWeek == 0) { dayOfWeek = 7; } c.add(Calendar.DATE, -dayOfWeek + 7); c.add(Calendar.WEEK_OF_MONTH, w); return c.getTime(); } }