if (cell.getCachedFormulaResultType() == Cell.CELL_TYPE_STRING) {
value = cell.getStringCellValue();
} else {
- value += cell.getNumericCellValue();
+ if (DateUtil.isCellDateFormatted(cell)) {
+ value = getFormattedDate(cell);
+ } else {
+ value += cell.getNumericCellValue();
+ }
}
break;
case XSSFCell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
- DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- value += sdf.format(cell.getDateCellValue());
+ value = getFormattedDate(cell);
} else {
value += cell.getRawValue();
}
return elementName.matches(".*:.*")?elementName.split(":")[1]:elementName;
}
-
+ private String getFormattedDate(XSSFCell cell) {
+ DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ return sdf.format(cell.getDateCellValue());
+ }
private Node getNodeByXPath(String xpath,Node rootNode,Document doc,boolean createMultipleInstances) {
String[] xpathTokens = xpath.split("/");
assertNotNull(xmlData);
assertFalse(xmlData.equals(""));
- String date = xmlData.split("<DATE>")[1].split("</DATE>")[0].trim();
- assertEquals("2012-01-13", date);
+ assertEquals("2012-01-13", xmlData.split("<DATE>")[1].split("</DATE>")[0].trim());
+ assertEquals("2012-02-16", xmlData.split("<FORMULA_DATE>")[1].split("</FORMULA_DATE>")[0].trim());
parseXML(xmlData);