如何解析日期字符串数组?
String startTime[] = stdata.toArray(new String[stdata.size()]);
SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
for(int ir=0;ir<startTime.length;ir++){
try {
parsed2d[ir] = inputFormat.parse(startTime[ir]);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
使用此代码,我得到: ArrayIndexOutOfBoundsException
编辑:
@Juvanis 你是对的!
最终代码工作:
String startTime[] = stdata.toArray(new String[stdata.size()]);
SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
for(int ir=0;ir<startTime.length;ir++){
try {
Date parsed2d[] = new Date[startTime.length];
parsed2d[ir] = inputFormat.parse(startTime[ir]);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}