When you import Excel today, background Java gets the cell time and converts it into a number, which is a string that converts a number to a time type.
1 Public StaticString Getcell (Hssfcell cell) {2DecimalFormat DF =NewDecimalFormat ("#");3 if(Cell = =NULL)4 return"";5 Switch(Cell.getcelltype ()) {6 CaseHssfcell.cell_type_numeric:7 if(hssfdateutil.iscelldateformatted (cell)) {8SimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");9 returnSdf.format (Hssfdateutil.getjavadate (Cell.getnumericcellvalue ())). ToString ();Ten } One returnDf.format (Cell.getnumericcellvalue ()); A Casehssfcell.cell_type_string: - System.out.println (Cell.getstringcellvalue ()); - returnCell.getstringcellvalue (); the CaseHssfcell.cell_type_formula: - returnCell.getcellformula (); - CaseHssfcell.cell_type_blank: - return""; + CaseHssfcell.cell_type_boolean: - returnCell.getbooleancellvalue () + ""; + CaseHssfcell.cell_type_error: A returnCell.geterrorcellvalue () + ""; at } - return""; -}View Code
Java Hssfcell Import get time, convert time by timestamp