The following code shows how to get all of the Mondays in the current year and the specified month.
import java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.Year; import java.time.temporal.TemporalAdjusters; // w ww . ja va 2 s. c om public class Main { public static void main(String[] args) { Month month = Month.valueOf("March".toUpperCase()); System.out.printf("For the month of %s:%n", month); LocalDate date = Year.now().atMonth(month).atDay(1). with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)); Month mi = date.getMonth(); while (mi == month) { System.out.printf("%s%n", date); date = date.with(TemporalAdjusters.next(DayOfWeek.MONDAY)); mi = date.getMonth(); } } }
The code above generates the following result.