Не проходит валидацию, как обычно.
По моему пониманию это:
if (calendar.get(Calendar.MONTH) > 4 && calendar.get(Calendar.MONTH) < 8){
iterator.remove();
}
должно удалить запись, но не проходит... Что не так?
Спасибо.
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("Бин", dateFormat.parse("MAY 1 2012"));
map.put("кузя", dateFormat.parse("MAY 1 2012"));
map.put("оне", dateFormat.parse("MAY 1 2012"));
map.put("Стал", dateFormat.parse("MAY 1 2012"));
map.put("лоне", dateFormat.parse("AUG 1 2012"));
map.put("С", dateFormat.parse("MAY 5 2012"));
map.put("Слон", dateFormat.parse("MAY 1 2012"));
map.put("аллон", dateFormat.parse("JUL 1 2012"));
map.put("е", dateFormat.parse("JUN 1 2012"));
return map;
}
public static void removeAllSummerPeople(Map<String, Date> map) {
Calendar calendar = new GregorianCalendar();
Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<String, Date> pair = iterator.next();
String key = pair.getKey();
Date value = pair.getValue();
if (calendar.get(Calendar.MONTH) > 4 && calendar.get(Calendar.MONTH) < 8){
iterator.remove();
}
}
}
public static void main(String[] args) {
}
}