miachm/SODS

Range.getValue() returns LocalDate instead of Date

mmitch opened this issue · 3 comments

The JavaDoc for Range.getValue() says

Returns the value of the top-left cell in the range.
The values could be String, Float, Integer, OfficeCurrency, OfficePercentage or a Date
Empty cells returns a null object

On my first try of SODS (version 1.5.2), reading a cell with a date gave me a java.time.LocalDate instead of a Date.

I like this because I want a LocalDate and don't have to write a conversion Date->LocalDate, but the documentation is a bit off.

Is the resulting type depending on the cell formatting? I have explicitely set the cell format to tt.mm.jjjj (like yyyy-mm-dd but for German locale) in the spreadsheet.

Thanks for your report! Please ensure you have provided enough info in order to recreate the issue, including the problematic ODS File.

The resulting type is parsed looking the attribute "office:value-type" in the XML. The date format should not matter. SODS convert all the dates to the UTC format.

But it's true the documentation is misleading. The type should be LocalDate, not Date.

Javadoc updated