I seem to be failing the last requirement, but I can't see where the flaw is in my code. I did face an issue with being forced to use Calendar because I kept getting a message that getMonth was deprecated. I don't know if that's where the error is, or if it's the removal of the key itself. Thanks in advance for any guidance you can provide!
package com.codegym.task.task08.task0816;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Iterator;
import java.util.Map;
import java.util.Calendar;
public class Solution {
public static HashMap<String, Date> createMap() throws ParseException {
DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
HashMap<String, Date> map = new HashMap<String, Date>();
map.put("Stallone", df.parse("JUNE 1 1980"));
map.put("Miguel", df.parse("JULY 26 1970"));
map.put("Franz", df.parse("JUNE 11 1952"));
map.put("Mikhael", df.parse("JULY 7 1939"));
map.put("Joseph", df.parse("JUNE 23 1947"));
map.put("Javier", df.parse("JULY 18 1963"));
map.put("Benjamin", df.parse("JUNE 14 2018"));
map.put("Steven", df.parse("MAY 26 1957"));
map.put("Gunther", df.parse("JUNE 3 1969"));
map.put("Lawrence", df.parse("JUNE 20 1984"));
return map;
}
public static void removeAllSummerPeople(HashMap<String, Date> map) {
Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry<String, Date> element = iterator.next();
Date myDate = element.getValue();
Calendar calendar = Calendar.getInstance();
calendar.setTime(myDate);
int currentMonth = calendar.get(Calendar.MONTH);
String myKey = element.getKey();
if (currentMonth > 5 && currentMonth < 8)
{
map.remove(myKey);
}
}
}
public static void main(String[] args) throws ParseException {
}
}