我在使用 apache poi 3.7 获取正确格式的日期时遇到问题 根据文档,我必须使用 DataFormatter 中的 formatCellValue 方法。 在这里,我找到了一些建议相同的答案,但它不起作用。
Excel 字段以 dd.MM.yyyy
格式显示日期:例如:09.06.2010
在使用 formatCellValue(Cell cell) 之后,我得到了 9/6/10。 我尝试使用和不使用 Local.German 或 Local.German 的 DataFormatter 和 HSSFDataFormatter
这是我的代码:
if( DateUtil.isCellDateFormatted(cell))
{
HSSFDataFormatter formatter = new HSSFDataFormatter(Locale.GERMAN);
String temp = formatter.formatCellValue(cell);
System.out.println(temp);
}
有人可以帮帮我吗?
最佳答案
我不确定,但我认为问题可能是您覆盖了其中一种默认日期格式的格式字符串。
这仅在 POI 3.8 beta 1 中得到修复(参见 changelog),因此我建议您尝试升级到 3.8 beta3,它有望解决您的问题。以前 POI 只是假定默认格式不会更改,因此会为它们使用默认格式字符串。
关于java - Apache POI 日期 dd.MM.yyyy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6467751/