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

Possibility to set date/time pattern #17

Closed ramonchu closed 4 years ago

ramonchu commented 4 years ago

Actually I'm getting this output for a LocalDate:

02/05/2020 00:00:00

It'll would be interesting that same valut outputs only the date.

miachm commented 4 years ago

Thanks for your report!

That it is quite strange because that was the intended behaviour. There is an automatic test to ensure the premise:

public void testDate()
{
    LocalDate now = LocalDate.now();
    LocalDate date = LocalDate.of(2002,3,3);
    LocalDateTime datetime = LocalDateTime.of(2006, 6, 6 , 14, 12, 32);

    Sheet sheet = new Sheet("A", 1, 3);
    sheet.getDataRange().setValues(now, date, datetime);
    sheet = saveAndLoad(sheet);

    assertEquals(sheet.getRange(0, 0).getValue(), now);
    assertEquals(sheet.getRange(0, 1).getValue(), date);
    assertEquals(sheet.getRange(0, 2).getValue(), datetime);
}

But if I use LibreOffice to open the file. I can see the 00:00:00. It looks like they assume it's a datetime even if I don't specify the time.

miachm commented 4 years ago

I have setted a default fomat for plain Date types. Now it should work like expected.

Set your own custom date format would be nice. I am registering a new Issue with this request.

Thanks