import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Test { 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 2 2011")); map.put("Даша", dateFormat.parse("MAY 17 1993")); map.put("Ира", dateFormat.parse("JUNE 3 2001")); map.put("Тася", dateFormat.parse("JULY 2 2011")); map.put("Петя", dateFormat.parse("AUGUST 2 2011")); map.put("Миша", dateFormat.parse("MAY 5 2005")); map.put("Саша", dateFormat.parse("MAY 4 1990")); map.put("Вова", dateFormat.parse("MAY 6 1999")); map.put("Гриша", dateFormat.parse("MARCH 10 1995")); Iterator<Map.Entry<String, Date>> it = map.entrySet().iterator(); while (it.hasNext()) { System.out.println(it.next()); } return map; } public static void removeAllSummerPeople(Map<String, Date> map) { Iterator<Map.Entry<String, Date>> i = map.entrySet().iterator(); while (i.hasNext()) { Date date = i.next().getValue(); int month = date.getMonth(); if (month == 5 || month == 6 || month == 7) { i.remove(); } } } public static void main(String[] args) throws ParseException { removeAllSummerPeople(createMap()); } }