0

I am trying to read a cell value which holds the date as a value with a custom format. Apache poi is returning me the value as a string(integer number).

DataFormatter formatter = new DataFormatter(); return formatter.formatCellValue(cell);

DataFormatter is not working. I am getting same value even

enter image description here

Rajiv525
  • 141
  • 2
  • 10
  • 2
    "DataFormatter is not working": For me `DataFormatter` works pretty good for each kind of date formatting and especially for the format you are showing. What `apache poi` version are you using? How does it look in Excel? (Screenshot, which shows the cell and the formula bar, please). Best would be a complete minimal reprodicible example. Sample Excel file to download and complete code to test. – Axel Richter Aug 08 '22 at 11:32
  • Getting the date value as 44763 for the given date – Rajiv525 Aug 08 '22 at 12:44
  • 1
    For me, using current `apache poi 5.2.2`, `DataFormatter` works as expected and returns a string in format `dd.MM.yyyy` in that case. As told, [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) please. – Axel Richter Aug 08 '22 at 12:50
  • I am using an older version 2.28.0, which is returning me the number of days from 01/01/1900. I will update the pom to the latest one and will give it a try. – Rajiv525 Aug 08 '22 at 13:24
  • Sorry version 4.0.1 – Rajiv525 Aug 08 '22 at 13:30
  • I've been doing [this](https://stackoverflow.com/a/3562214/230513) for over a decade, currently with `poi-5.2.2`. – trashgod Aug 08 '22 at 17:30

0 Answers0