Can someone please give me a tip what I'm doing wrong here? I get correct results in Eclipse.
Thank you!
package de.codegym.task.task08.task0816;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/*
Die liebe Emma und die Sommerferien
*/
public class Solution {
public static HashMap<String, Date> mapErstellen() throws ParseException {
DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
HashMap<String, Date> map = new HashMap<String, Date>();
map.put("Stallone", df.parse("SEPTEMBER 1 1980"));
map.put("el", df.parse("MARCH 1 1980"));
map.put("em", df.parse("JANUARY 1 1985"));
map.put("es", df.parse("JUNE 1 1989"));
map.put("ep", df.parse("JUNE 9 1990"));
map.put("er", df.parse("JULY 1 1980"));
map.put("we", df.parse("DECEMBER 1 1980"));
map.put("qw", df.parse("APRIL 19 1995"));
map.put("ds", df.parse("JUNE 12 2019"));
map.put("ay", df.parse("AUGUST 31 2006"));
return map;
}
public static void alleSommergeburtstagskinderEntfernen(HashMap<String, Date> map) throws ParseException {
Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();
DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
String s = "MAY 31 1970";
String e = "SEPTEMBER 1 2020";
Date start = df.parse(s);
Date end = df.parse(e);
while (iterator.hasNext()) {
Map.Entry<String, Date> wert = iterator.next();
Date value = wert.getValue();
if (value.after(start) && value.before(end)) {
iterator.remove();
}
}
}
public static void main(String[] args) {
}
}