开发者

Apache POI date dd.MM.yyyy

I have problems to get date in right format using apache poi 3.7 According the documentation I have to use the formatCellValue Method from DataFormatter. Here I found a few answers which advise the same, but it don´t works.

The excel field shows the date in for开发者_运维知识库mat dd.MM.yyyy: for ex: 09.06.2010

After using formatCellValue(Cell cell) I get 9/6/10. I try DataFormatter and HSSFDataFormatter with and without Local.German or Local.German

Here is my code:

if( DateUtil.isCellDateFormatted(cell))
{
    HSSFDataFormatter formatter = new HSSFDataFormatter(Locale.GERMAN);
    String temp = formatter.formatCellValue(cell);
    System.out.println(temp);
}

Can somebody help me?


I'm not certain, but I think the issue might be that you've overridden the format string of one of the default date formats.

This was only fixed in POI 3.8 beta 1 (see the changelog), so I'd suggest you try upgrading to 3.8 beta3 and it will hopefully fix your issue. Previously POI just assumed that the default formats wouldn't have been changed, so would use the default format string for them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜