I dn't know if in California the summer months are different.
package en.codegym.task.jdk13.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.Map;
/*
Remove all people born in the summer
*/
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("Smith", dateFormat.parse("MAY 1 2012"));
//write your code here
map.put("Johnson", dateFormat.parse("JUN 22 2000"));
map.put("Harris", dateFormat.parse("JUL 15 1950"));
map.put("Murray", dateFormat.parse( "AUG 12 1955"));
map.put("MacBrian", dateFormat.parse("SEP 20 1956"));
map.put("Dickinson", dateFormat.parse("OCT 14 1957"));
map.put("Di Anno", dateFormat.parse("NOV 10 1958"));
map.put("Ulrich", dateFormat.parse("DEC 1 1958"));
map.put("Hetfield", dateFormat.parse("JAN 2 1959"));
map.put("Hammett", dateFormat.parse("FEB 2 1960"));
return map;
}
public static void removeAllSummerPeople(Map<String, Date> map) {
//write your code
HashMap<String, Date> copy = new HashMap<String, Date>(map);
for(Map.Entry<String, Date> pair : copy.entrySet())
{
if(pair.getValue().getMonth() == 6 || pair.getValue().getMonth() == 7)
{
map.remove(pair.getKey());
}
if(pair.getValue().getMonth() == 5 && pair.getValue().getDay() >= 21)
{
map.remove(pair.getKey());
}
if(pair.getValue().getMonth() == 8 && pair.getValue().getDay() <= 21)
{
map.remove(pair.getKey());
}
}
}
public static void main(String[] args) {
}
}