import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		// Test
		System.out.println(getWeekends(2));// All weekends of Feb in the current year
		System.out.println(getWeekends(2020, 2));// All weekends of Feb 2020
	}

	/*
	 * All weekends (Sat & Sun) of the given month in the current year
	 */
	static List<LocalDate> getWeekends(int month) {
		LocalDate firstDateOfTheMonth = LocalDate.now().withMonth(month).with(TemporalAdjusters.firstDayOfMonth());
		
		return firstDateOfTheMonth
				.datesUntil(firstDateOfTheMonth.plusMonths(1))
				.filter(date -> date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)
				.collect(Collectors.toList());
	}

	/*
	 * All weekends (Sat & Sun) of the given year and the month
	 */
	static List<LocalDate> getWeekends(int year, int month) {
		LocalDate firstDateOfTheMonth = YearMonth.of(year, month).atDay(1);
		
		return firstDateOfTheMonth
				.datesUntil(firstDateOfTheMonth.plusMonths(1))
				.filter(date -> date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)
				.collect(Collectors.toList());
	}
}