Hi,

I noticed that jOpenDocument 1.3 seems to store time values in an incorrect 
format.
For example, consider:
    SpreadSheet spreadSheet = SpreadSheet.create(1, 1, 1);
    Sheet sheet = spreadSheet.getFirstSheet();
    sheet.getCellAt(0, 0).setValue(
        Calendar.getInstance(),
        ODValueType.TIME,
        true,
        true
      );
    spreadSheet.saveAs(new File("TimeValueTest.ods"));
The problem is due to    
org.jopendocument.dom.ODValueType.format(Object)returning    
TimeUtils.timePartToDuration(cal).toString()that finally produces something 
like    <table:table-cell office:value-type="time" 
office:time-value="P0Y0M0DT20H42M31.234S">
      <text:p>8:42:31 PM</text:p>
    </table:table-cell>, which LibreOffice in turn interpretes as "12:00:00 AM".
[I'm using version 3.5.7.2, Build ID: 350m1(Build:2).]According to 
http://books.evc-cit.info/odbook/ch05.html#table-number-cells-section, an 
office:time-value should be stored in the form PThhHmmMss,ffffS (where ffff is 
the fractional part of a second).
Replacing    return TimeUtils.timePartToDuration(cal).toString()in    
org.jopendocument.dom.ODValueType.format(Object)with    Duration duration = 
TimeUtils.timePartToDuration(cal);
    double seconds = duration.getField(DatatypeConstants.SECONDS).doubleValue();
    return String.format("PT%02dH%02dM%07.4fS", duration.getHours(), 
duration.getMinutes(), seconds);gives    <table:table-cell 
office:value-type="time" office:time-value="PT20H42M31.2340S">
      <text:p>8:42:31 PM</text:p>
    </table:table-cell>, which seems to work correctly.

Cheers,

Manfred

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"jOpenDocument" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jopendocument+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to