Bug 56269

Summary: DateFormat - Rounding of fractionals
Product: POI Reporter: Andreas Beeker <kiwiwings>
Component: XSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.11-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Bug Depends on:    
Bug Blocks: 54071    
Attachments: different fractional rounding before save/load in Libre Office
[PATCH] Round fractionals to seconds

Description Andreas Beeker 2014-03-15 13:03:01 UTC
Created attachment 31391 [details]
different fractional rounding before save/load in Libre Office

In our project we discovered some rounding problem with date fractions.
We've got some data from a database tool (TOAD) which minimal calculated fractions differently, but the result when opening the file was ok.
But the DateUtil class uses the real milliseconds and therefore output 03.01.2014 10:59:59 instead of 11:00:00 (fraction was 41642.45833321759)

After playing around with the fractions, it seems that at least Libre Office will round at 500 millisecs.
Actually when recalculate the second date in the example file, it will be saved as 10:59:59, but when reopening it will be 11:00:00.

MS Excel Viewer can't be forced to recalc via [1] and I haven't check with project laptops Excel version ...

Should this rounding be taken into account in the DateUtil class?

[1] http://apache-poi.1045710.n5.nabble.com/How-to-force-Excel-to-recalculate-on-opening-xlsx-td3249595.html
Comment 1 Andreas Beeker 2014-05-04 21:11:02 UTC
Created attachment 31588 [details]
[PATCH] Round fractionals to seconds

The patch adds another formatting option to the DateUtil class, to get rounded dates. I think, this should be the default, to have the date values rounded to seconds, but for the sake of compatibility I left the behavior unchanged.
Comment 2 Andreas Beeker 2014-05-04 21:18:23 UTC
applied with svn rev r1592419