the code pass the run but not the verification
i think to convert the Date to a String to could test if the String contains the month.
i think it s logical .i dont pass the verification and i dont know where is the fault?
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;
/*
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("Henry", df.parse("September 17 1985"));
map.put("Elvis", df.parse("February 12 1975"));
map.put("Carmen", df.parse("April 9 1996"));
map.put("Nadia", df.parse("Mai 1 1988"));
map.put("Iosif", df.parse("November 4 2001"));
map.put("Adam", df.parse("August 5 2004"));
map.put("Lucas", df.parse("December 20 2006"));
map.put("Maria", df.parse("January 17 1984"));
map.put("Gabriel", df.parse("November 17 1986"));
return map;
}
public static void removeAllSummerPeople(HashMap<String, Date> map) {
DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
Iterator<Map.Entry<String,Date>> itr = map.entrySet().iterator();
while(itr.hasNext())
{
Map.Entry<String,Date> pair = itr.next();
Date value = pair.getValue();
String strDate = value.toString();
if(strDate.contains("June") || strDate.contains("July") || strDate.contains("August"))
itr.remove();
}
}
public static void main(String[] args) {
}
}