miachm / SODS

A simple Java library for handle ODS (Open Document Spreadsheet, compatible with Excel and Libreoffice)
The Unlicense
74 stars 30 forks source link

Range.getValue() returns LocalDate instead of Date #54

Closed mmitch closed 1 year ago

mmitch commented 1 year ago

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.

github-actions[bot] commented 1 year ago

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

miachm commented 1 year ago

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.

miachm commented 1 year ago

Javadoc updated