poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49843] New: DateUtil.getJavaDate() fringe cases
Date Mon, 30 Aug 2010 11:39:03 GMT

           Summary: DateUtil.getJavaDate() fringe cases
           Product: POI
           Version: 3.6-dev
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
        AssignedTo: dev@poi.apache.org
        ReportedBy: i8c.alex@gmail.com

The DateUtil.getJavaDate() service uses a calendar with the local timezone to
transform an excel double into a java.util.Date.

Consider however the following example:
A user fills in "00:00" in a cell and formats it as a time. The user then
"drags" the bottom right corner downwards until row "27" is reached. This row
will read "02:00:00". 

Because excel starts counting on the 31st of december 1899, rows 25, 26 and 27
are times expressed on the 1st of january 1900. Suppose that the system default
for timezone is "Europe/Paris". If i then wish to format that date with
SimpleDateFormat with timezone set to the same default, everything works fine:
1899-12-31 22:00:00 CET 
1899-12-31 23:00:00 CET 
1900-01-01 00:00:00 CET 
1900-01-01 01:00:00 CET 
1900-01-01 02:00:00 CET 

However if we set the timezone of the simpledateformat to "UTC", we get the
1899-12-31 22:00:00 UTC 
1899-12-31 23:00:00 UTC 
1900-01-01 00:50:39 UTC 
1900-01-01 01:50:39 UTC 

If we set the system timezone to UTC (so the calendar uses UTC) then everything
works again. Also note the results for default timezone "Europe/Brussels" with
formatting for "UTC":
1899-12-31 22:00:00 UTC 
1900-01-01 00:00:00 UTC 
1900-01-01 01:00:00 UTC 
1900-01-01 02:00:00 UTC 

Can we get an overloaded getJavaDate() call where we can define the timezone
for the calendar in question?

The attachment is an example xlsx with java code.

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message