Pls, hint with explanation, tk you! :)
package com.codegym.task.task19.task1904;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Scanner;
/*
Yet another adapter
*/
public class Solution {
public static void main(String[] args) {
}
public static class PersonScannerAdapter implements PersonScanner {
private Scanner fileScanner;
public PersonScannerAdapter(Scanner fileScanner){
this.fileScanner = fileScanner;
}
@Override
public Person read() throws IOException {
Person person1 = null;
String person = fileScanner.nextLine();//read next line(nextPerson)
String lastName = person.substring(0, person.indexOf(" "));//save text until first space
person = person.substring(lastName.length()+1);//read from lastName.length()+1
String middleName = person.substring(0, person.indexOf(" "));//save text until first space
person = person.substring(middleName.length()+1);//...
String firstName = person.substring(0, person.indexOf(" "));//...
String birthDate = person.substring(firstName.length()+1);//read text from firstName.length()+1
//how can i save the date(birthDate) in format MM DD YYYY???
return new Person(firstName, middleName, lastName, birthDate);//not string, but Date tipe!?
}
@Override
public void close() throws IOException {
fileScanner.close();
}
}
}