I keep getting an error on line 60. It says, "unreported exception java.text.ParseException; must be caught or declared to be thrown" I've looked it up and everything i'm reading says I have an error in my date formats, but I can't figure out what it would be, as they all seem to be formatted the same way.
package com.codegym.task.task08.task0816;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar;
import java.util.Map;
import java.util.Locale;
import java.util.Iterator;
import java.util.Date;
import java.util.HashMap;
/*
Kind Emma and the summer holidays
*/
public class Solution {
public static HashMap<String, Date> createMap() throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
HashMap<String, Date> map = new HashMap<>();
map.put("Stallone", dateFormat.parse("JUNE 1 1980"));
map.put("Pace", dateFormat.parse("JANUARY 9 2018"));
map.put("Jones", dateFormat.parse("SEPTEMBER 1 1999"));
map.put("Bloomquist", dateFormat.parse("MARCH 5 1991"));
map.put("Legg", dateFormat.parse("NOVEMBER 8 1989"));
map.put("Nash", dateFormat.parse("JUNE 7 1995"));
map.put("Paterson", dateFormat.parse("APRIL 4 1980"));
map.put("Gold", dateFormat.parse("JULY 3 1971"));
map.put("Redd",dateFormat.parse("AUGUST 2 1990"));
map.put("Blue", dateFormat.parse("DECEMBER 5 1999"));
return map;
}
public static void removeAllSummerPeople(HashMap<String, Date> map) {
Calendar cal = Calendar.getInstance();
Iterator<Map.Entry<String,Date>> itr = map.entrySet().iterator();
while (itr.hasNext()){
Map.Entry<String,Date> entry = itr.next();
cal.setTime(entry.getValue());
if (cal.get(Calendar.MONTH)== 5 || cal.get(Calendar.MONTH)== 6 || cal.get(Calendar.MONTH)== 7){
itr.remove();
}
}
}
public static void main(String[] args) {
HashMap<String, Date> nameMap = new HashMap<>();
nameMap = createMap(); // unhandled exception here
removeAllSummerPeople(nameMap);
}
}