package fr.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;
/*
La gentille Emma et les vacances d'été
*/
public class Solution {
public static HashMap<String, Date> creerMap() 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("Di Caprio", df.parse("NOVEMBER 11 1974"));
map.put("Pitt", df.parse("DECEMBER 18 1963"));
map.put("Einstein", df.parse("MARCH 14 1879"));
map.put("Rodrigo", df.parse("JUNE 23 1968"));
map.put("De Niro", df.parse("AUGUST 17 1943"));
map.put("Connery", df.parse("AUGUST 25 1930"));
map.put("Macron", df.parse("DECEMBER 21 1977"));
map.put("Trump", df.parse("JUNE 14 1946"));
map.put("Deneuve", df.parse("OCTOBER 22 1943"));
return map;
}
public static void supprimerToutesPersonnesEte(HashMap<String, Date> map) throws ParseException {
DateFormat df = new SimpleDateFormat("MMMMM", Locale.ENGLISH);
for (Map.Entry<String, Date> obj : map.entrySet()){
Date value = obj.getValue();
String key = obj.getKey();
if (value == df.parse("JUNE") || value == df.parse("JULY") || value == df.parse("AUGUST")){
map.remove(key);
}
}
}
public static void main(String[] args) {
}
}
package fr.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;
/*
La gentille Emma et les vacances d'été
*/
public class Solution {
public static HashMap<String, Date> creerMap() 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("Di Caprio", df.parse("NOVEMBER 11 1974"));
map.put("Pitt", df.parse("DECEMBER 18 1963"));
map.put("Einstein", df.parse("MARCH 14 1879"));
map.put("Rodrigo", df.parse("JUNE 23 1968"));
map.put("De Niro", df.parse("AUGUST 17 1943"));
map.put("Connery", df.parse("AUGUST 25 1930"));
map.put("Macron", df.parse("DECEMBER 21 1977"));
map.put("Trump", df.parse("JUNE 14 1946"));
map.put("Deneuve", df.parse("OCTOBER 22 1943"));
return map;
}
public static void supprimerToutesPersonnesEte(HashMap<String, Date> map) throws ParseException {
DateFormat df = new SimpleDateFormat("MMMMM", Locale.ENGLISH);
for (Map.Entry<String, Date> obj : map.entrySet()){
Date value = obj.getValue();
String key = obj.getKey();
if (value == df.parse("JUNE") || value == df.parse("JULY") || value == df.parse("AUGUST")){
map.remove(key);
}
}
}
public static void main(String[] args) {
}
}