Here you can find the source of getAllDaysDateBetween(Date startDate, Date endDate, DayOfWeek dayOfWeek)
public static List<Date> getAllDaysDateBetween(Date startDate, Date endDate, DayOfWeek dayOfWeek)
//package com.java2s; //License from project: Apache License import java.time.DayOfWeek; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class Main { public static List<Date> getAllDaysDateBetween(Date startDate, Date endDate, DayOfWeek dayOfWeek) { Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate);//w w w . ja v a 2s .c om Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); ArrayList<Date> daysDateList = new ArrayList<>(); while (!startCal.equals(endCal)) { startCal.add(Calendar.DATE, 1); if (startCal.get(Calendar.DAY_OF_WEEK) == dayOfWeek.getValue()) { daysDateList.add(startCal.getTime()); } } return daysDateList; } }