So everything checks out by the mentor except for the date. Even though I think I did everything by the book, SDF won't format my date in the desired output.
What am I missing?
package com.codegym.task.task19.task1921;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
/*
John Johnson
*/
public class Solution {
public static final List<Person> PEOPLE = new ArrayList<>();
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new FileReader(args[0]));
String[] splitLine;
LinkedList<Integer> birthDay = new LinkedList<>();
StringBuilder lineName ;
StringBuilder birthdate2 = new StringBuilder();
while (bf.ready())
{
lineName = new StringBuilder();
splitLine = bf.readLine().split(" ");
for (int i = 0; i < splitLine.length; )
{
//check to see if the first element is a number. if not, add it to the namelist
try { birthDay.add(Integer.parseInt(splitLine[i]));
birthdate2.append(splitLine[i] + " ");
} catch (NumberFormatException nfe) {
lineName.append(splitLine[i] + " ");
}
i++;
}
//so far so good
String name = lineName.toString().trim();
String sDate1= birthDay.get(0) + " " + birthDay.get(1) + " " + birthDay.get(2);
Date date1 = new SimpleDateFormat("MM dd yyyy").parse(sDate1);
//printting date1 does it like this. what the hell ? Thu Dec 31 00:00:00 EET 1987
Person person = new Person(name, date1);
PEOPLE.add(person);
person.toString();
}
bf.close();
}
}