car
public class TestMain {
public static void main(String[] args) {
int n = 1;//输入的日期数字1-7
LocalDate date = LocalDate.now();
int year = date.getYear();
LocalDate startDate = LocalDate.parse(year+"-01-01");
LocalDate endDate = LocalDate.parse(year+"-12-31");
int startDay = startDate.getDayOfYear();
int endDay = endDate.getDayOfYear();
DayOfWeek dayOfWeek = null;
while (startDay <= endDay) {
dayOfWeek = startDate.getDayOfWeek();
int value = dayOfWeek.getValue();
if (value == n) {
System.out.println(startDate);
}
startDate = startDate.plusDays(1);
startDay++;
}
}
}