Не проходит проверка на пункт: Метод removeAllSummerPeople() должен удалять из словаря всех людей, родившихся летом.
Вывожу map на экран - всё удаляет. Подскажите почему валидатор ругается?
package com.javarush.task.task08.task0816;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/*
Добрая Зинаида и летние каникулы
*/
public class Solution {
public static Map<String, Date> createMap() throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
Map<String, Date> map = new HashMap<>();
map.put("Сталлоне", dateFormat.parse("MAY 1 2012"));
map.put("1", dateFormat.parse("MAY 1 2012"));
map.put("12", dateFormat.parse("MAY 1 2012"));
map.put("2", dateFormat.parse("MAY 1 2012"));
map.put("3", dateFormat.parse("MAY 1 2012"));
map.put("4", dateFormat.parse("MAY 1 2012"));
map.put("5", dateFormat.parse("AUG 1 2012"));
map.put("6", dateFormat.parse("MAY 1 2012"));
map.put("7", dateFormat.parse("JULY 1 2012"));
map.put("8", dateFormat.parse("JUNE 1 2012"));
return map;
//напишите тут ваш код
}
public static void removeAllSummerPeople(Map<String, Date> map) {
ArrayList<String> keys = new ArrayList<>();
for (Map.Entry<String, Date> list : map.entrySet()) {
Calendar cal = Calendar.getInstance();
cal.setTime(list.getValue());
int month = cal.get(Calendar.MONTH);
if (month >= 5 && month <= 8) {
keys.add(list.getKey());
}
}
for (String str: keys) {
map.remove(str);
}
}
public static void main(String[] args) throws ParseException {
Map<String, Date> map = createMap();
removeAllSummerPeople(map);
// for (Map.Entry<String, Date> list: map.entrySet()) {
// System.out.println(list.getKey() + " " + list.getValue());
// }
}
}