Here you can find the source of getMonday(String date, int weekDay)
public static Date getMonday(String date, int weekDay)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getMonday(String date, int weekDay) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date d = null;//w w w . j ava 2s.com try { d = format.parse(date); } catch (Exception e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (d != null) { cal.setTime(d); } // DAY_OF_WEEK // Field number for get and set indicating // the day of the week. This field takes values // SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, // and SATURDAY cal.set(Calendar.DAY_OF_WEEK, weekDay); cal.add(Calendar.DATE, 1); return cal.getTime(); } }