如何解析字符串数组日期?
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();
}
}