我编写了一个程序,它得到一个ParseException,因为我正在尝试使用toString()方法解析数组的日期。
public static final List<Person> PEOPLE = new ArrayList<Person>();
BufferedReader reader = new BufferedReader(new FileReader(nameFile));
ArrayList<String> name = new ArrayList<>();
ArrayList<String> rowdate = new ArrayList<>();
while (reader.ready())
{
String [] rowdata = reader.readLine().split(" ");
for(int i=0; i < rowdata.length; i++)
{
if(!rowdata[i].matches(".*[\\d]+.*"))
{
name.add(rowdata[i]);
}
else rowdate.add(rowdata[i]);
}
DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
Date startDate = df.parse(rowdate.toString());
String lel = name.toString();
PEOPLE.add(new Person(lel, startDate));
}
通常,它会像[10, 01, 1987];
问题是如何(如果可能)这样做10/01/1987;
提前致谢!