Help please
on my computer it works
To be sur, I tested the code bellow:
for (Person P : PEOPLE) {
System.out.format("%s né le %tD %n",P.getName(),P.getBirthDate());
}
And I had :
John Jack Johnson né le 12/31/87
Vincent né le 05/15/13
thankspackage fr.codegym.task.task19.task1921;
import java.text.ParseException;
import java.util.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.regex.*;
/*
John Johnson
*/
public class Solution {
public static final List<Person> PEOPLE = new ArrayList<>();
public static void main(String[] args) throws IOException, ParseException {
BufferedReader reader = new BufferedReader(new FileReader(args[0]));
Pattern patternName = Pattern.compile("[a-zA-Z].+[a-zA-Z]");
Pattern patternDate = Pattern.compile("\\d.+");
while(reader.ready()) {
String line = reader.readLine();
String name = "";
String date = "";
SimpleDateFormat df = new SimpleDateFormat("MM dd yyyy");
Matcher matcherName = patternName.matcher(line);
while (matcherName.find()) {
name = line.substring(matcherName.start(),matcherName.end());
}
Matcher matcherDate = patternDate.matcher(line);
while (matcherDate.find()) {
date = line.substring(matcherDate.start(),matcherDate.end());
}
Date birthDate = df.parse(date);
PEOPLE.add(new Person(name, birthDate));
}
reader.close();
}
}