0
当我尝试从excel文件导入数据时出现错误(无法解析日期:“18-11-2003”)。从该文件的日期不能被解析无法从excel文件导入数据
if(row.getCell(16)!=null){
String dobb=null;
Date dob=null;
row.getCell(16).setCellType(row.getCell(16).CELL_TYPE_STRING);
dobb=row.getCell(16).getStringCellValue();
System.out.println(dobb);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
try {
dob = (Date)simpleDateFormat.parse(dobb);//error..... Unparseable date: "18–11–2003"
System.out.println("dateeee"+dob);
} catch (ParseException e) {
e.printStackTrace();
//dob=new Date();
}
日期格式u能粘贴控制台日志.Areü确保从Excel中传来的日期为dd-MM-yyyy格式? – Deepak
是...我得到d日期lyk这个18-11-2003 – user3048068
18-11-2003 java.text.ParseException:Unparseable date:“18-11-2003” \t at java.text.DateFormat.parse( DateFormat.java:357) – user3048068