Here you can find the source of getWeekDay(Date dt, int weekDay)
public static Date getWeekDay(Date dt, int weekDay)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getWeekDay(Date dt, int weekDay) { Calendar cal = new GregorianCalendar(); cal.setTime(dt);/*from w ww . j a v a 2s. c o m*/ if (weekDay == 7) weekDay = 1; else weekDay++; cal.set(GregorianCalendar.DAY_OF_WEEK, weekDay); return cal.getTime(); } }