Here you can find the source of getImmediateDayOfWeek(Calendar current, int dayOfWeek)
public static Calendar getImmediateDayOfWeek(Calendar current, int dayOfWeek)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static Calendar getImmediateDayOfWeek(Calendar current, int dayOfWeek) { Calendar immediateDayOfWeek = (Calendar) current.clone(); immediateDayOfWeek.add(Calendar.DAY_OF_MONTH, 1); while (immediateDayOfWeek.get(Calendar.DAY_OF_WEEK) != dayOfWeek) { immediateDayOfWeek.add(Calendar.DAY_OF_MONTH, 1); }/*from w ww . ja v a 2s. c o m*/ return immediateDayOfWeek; } }