Here you can find the source of getWeekDayOfYear(Date date)
public static List<Date> getWeekDayOfYear(Date date)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class Main { private static final int DAYS_OF_A_WEEK = 7; public static List<Date> getWeekDayOfYear(Date date) { Calendar calendar = getCalendarFromDate(date); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(DAYS_OF_A_WEEK); int week = calendar.get(Calendar.WEEK_OF_YEAR); int year = calendar.get(Calendar.YEAR); List<Date> result = new ArrayList<Date>(); result.add(getDateOfYearWeek(year, week, Calendar.MONDAY)); result.add(getDateOfYearWeek(year, week, Calendar.TUESDAY)); result.add(getDateOfYearWeek(year, week, Calendar.WEDNESDAY)); result.add(getDateOfYearWeek(year, week, Calendar.THURSDAY)); result.add(getDateOfYearWeek(year, week, Calendar.FRIDAY)); result.add(getDateOfYearWeek(year, week, Calendar.SATURDAY)); result.add(getDateOfYearWeek(year, week, Calendar.SUNDAY)); return result; }//w w w . j a va2 s . c om /** * get calendar from date * * @param date the passing date * @return the calendar instance */ public static Calendar getCalendarFromDate(Date date) { Calendar calendar = getDefaultCalendar(); calendar.setTime(date); return calendar; } private static Date getDateOfYearWeek(int yearNum, int weekNum, int dayOfWeek) { Calendar cal = Calendar.getInstance(); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.set(Calendar.DAY_OF_WEEK, dayOfWeek); cal.setMinimalDaysInFirstWeek(DAYS_OF_A_WEEK); cal.set(Calendar.YEAR, yearNum); cal.set(Calendar.WEEK_OF_YEAR, weekNum); /*cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0);*/ return cal.getTime(); } /** * get the default calendar * * @return the calendar instance */ public static Calendar getDefaultCalendar() { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); return calendar; } }