You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ro...@us.ibm.com on 2003/09/24 23:40:05 UTC
java.util.Date, time zones and HSSFCell.getDateCellValue()
What's the convention we have for Dates in Excel?
My understanding was the timestamps were stored in GMT/UTC no matter where
the user was. So, if I type 3:00pm in a cell, it would appear as 3:00pm
even if I opened it in an other time zone.
In that sense, it is a far different beast than java's Date object which
represents a single instance in time, once which can be reinterpreted in
different timezones. So, if I do a new Date() here in Boston at 5:30pm
and serialize the Date object and send it to someone to open in London, it
will appear to them as 9:30pm.
So, here's the confusing part. If I make an Excel sheet and put 7/4/2000
into a cell, if I query HSSFCell.getDateCellValue() for that cell, I get a
value of "Tue Jul 04 00:00:00 EDT 2000". But if someone in Chicago opened
the same file, they would get a value of "Tue Jul 04 00:00:00 CDT 2000".
So, each user is getting a value relative to their current time zone. This
doesn't seem correct, because these Date objects are different for the
same document.
I'm wondering whether we should patch the code, in HSSFDateUtils.java, so
the returned are all pegged to the same timezone (UTC).
Or am I missing something obvious? (increasingly a possibility)
-Rob