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

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());
		List<LocalDate> list = new ArrayList<>();

		for (LocalDate date = firstDateOfTheMonth; !date
				.isAfter(firstDateOfTheMonth.with(TemporalAdjusters.lastDayOfMonth())); date = date.plusDays(1))
			if (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)
				list.add(date);

		return list;
	}

	/*
	 * 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);
		List<LocalDate> list = new ArrayList<>();

		for (LocalDate date = firstDateOfTheMonth; !date
				.isAfter(firstDateOfTheMonth.with(TemporalAdjusters.lastDayOfMonth())); date = date.plusDays(1))
			if (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)
				list.add(date);

		return list;
	}
}