Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 format 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?

like image 823
Rafael Avatar asked Nov 04 '22 19:11

Rafael


1 Answers

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.

like image 147
Gagravarr Avatar answered Nov 11 '22 14:11

Gagravarr