Recently read Excel with a POI and passed in the database, but there was a very wonderful problem that has been bothering me for a long time
is read when the date type appears the year and day read correctly, but the month is 00 case, I have been looking for a long time, have been unable to find the reason
When I found out today, I was careless.
Previous error code:
Date Time=new date (); Time=cell.getdatecellvalue ();//Output SimpleDateFormat df=new SimpleDateFormat in the specified format ("Yyyy/mm/dd hh: Mm:ss "); SYSTEM.OUT.PRINTLN ("Imported Time:" +time+ " " +df.format ");
The result of this output is
Time to import: Thu 00:00:00 CST 2015 2015/00/01 12:00:00
It is the right one to read, but after formatting, there is a problem of month 00. This is a mistake in the format of the definition of a careless
SimpleDateFormat df=new SimpleDateFormat ("yyyy/mm/dd hh:mm:ss"); should read
SimpleDateFormat df=new SimpleDateFormat ("yyyy/MM/dd hh:mm:ss");
Otherwise the month is assigned by the sub-assignment, but the default is 00, so this error will occur
Problems with the date type when Java reads Excel with POI