简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM