I'm trying to read dates formatted like "07/27/1955" from an xlsx file, but I'm getting incorrect dates. Every date that I've tried returns a date of eithe
Here's what I currently have after looking at @Sayantam's answer here: https://stackoverflow.com/a/7261427/9659160
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
CellValue cValue = evaluator.evaluate(currCell);
double dv = cValue.getNumberValue();
if (DateUtil.isCellDateFormatted(currCell)) {
Date date = HSSFDateUtil.getJavaDate(dv);
String dateFmt = currCell.getCellStyle().getDataFormatString();
String strValue = new CellDateFormatter(dateFmt).format(date);
System.out.println(strValue);
}
This returns 6/20/04 when 07/27/1955 is in the excel file.
For that same value
currCell.getStringCellValue()
returns 20297
currCell.getDateCellValue()
returns Mon Jun 20 00:00:00 EST 1904
currCell.getNumericCellValue()
returns 1633.0