I try to debug and insert sout on verifying month - 45 row - (it come in but did not remove)...
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.Map;
/*
Kind Emma and the summer holidays
*/
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("Bel", df.parse("MAY 3 1980"));
map.put("Seb", df.parse("DECEMBER 1 1980"));
map.put("cIP", df.parse("OCTOBER 1 1980"));
map.put("sACCO", df.parse("NOVEMBER 1 1980"));
map.put("FETU", df.parse("MARCH 1 1980"));
map.put("tONY", df.parse("JUNE 2 1980"));
map.put("Fetu", df.parse("AUGUST 3 1980"));
map.put("Stal", df.parse("JUNE 15 1980"));
map.put("Stalle", df.parse("JULY 23 1980"));
//write your code here
return map;
}
public static void removeAllSummerPeople(HashMap<String, Date> map) /*throws ParseException*/ {
// map.entrySet().removeIf(pair->pair.getValue().getMonth()>5 & pair.getValue().getMonth()<9);
for (Map.Entry<String,Date> el:map.entrySet()
) {
String k = el.getKey();
Date ins = el.getValue();
String[] date = String.valueOf(ins).split(" ");
String month = date[1];
if(month.equalsIgnoreCase("Jun") || month.equalsIgnoreCase("Jul") || month.equalsIgnoreCase("Aug")){
//System.out.println("entra");
map.remove(ins);
}
}
}
public static void main(String[] args) /*throws ParseException*/ {
// HashMap<String,Date> elm = createMap();
//
// removeAllSummerPeople(elm);
}
}