【发布时间】:2014-07-17 15:39:39
【问题描述】:
先生,我正在将 Excel 表导入 MySql 数据库,一个单元格包含格式为 2013-12-30 (YYYY-MM-DD) 的日期。在 Importing 上,我将 Date 的值设为数字 40248.0,因为日期格式显示为 2013-12-30,但双击单元格显示为 30/12/2013。请解决。谢谢
if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
{
System.out.println(" The rowvalue is Numeric so Moving ahead");
String str = String.valueOf(cell.getNumericCellValue());
System.out.println(" String ---->"+str);
list1.add(str);
}
....
// some more code
String failure_date= list.get(5).toString();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd",Locale.ENGLISH);
Date failure_date1= null;
String new_date = null;
try{failure_date1 =(Date)df.parse(failure_date);
new_date=df.format(failure_date1);
}catch(Exception ex){ex.printStackTrace();}
System.out.println(" The failure_date is "+ new_date);
【问题讨论】:
标签: mysql excel date date-format