Hummmm... Use BiffViewer to confirm the files use 1904 date windowing (there is a record called 1904 something or other).. Anyone on the dev lisk know anything about the algorythm for 1904 dates???
-Andy

Dan Sherman wrote:

Hi!

I have code that will be used to read Excel files saved on both the PC
(Office 97 and 2000) and the Mac (Office v.X). I am having a problem
converting the Excel date representation to the correct Java date
representation with the files saved on the Mac. I'm guessing that Excel
on the Mac is saving dates using 1904 windowing. The HSSFDateUtil class
assumes 1900-based dates, so returns the incorect Java date. For example:

Date in Excel file (created via Excel v.X on the Mac): 11/05/02
code:
...
if (HSSFDateUtil.isCellDateFormatted(cell)) {
Date d = HSSFDateUtil.getJavaDate(cell.getNumericCellValue());
System.out.println(d);
}
...
The output is: Wed Nov 04 00:00:00 PST 1998 (11/4/98 -
incorrect)

If I do the same thing with a file saved from Excel 97 on the PC, I get:
Tue Nov 05 00:00:00 PST 2002 (11/5/02 - correct)


Is there a way to get the correct Java date for both of these files? Can
I somehow tell if the file I'm reading is using 1904 windowing and do the
date conversion accordingly? If so, how? I'm not interested in writing
in this format, I just want to make sure I get the dates right in the
files that I'm reading.

Thanks!

Dan Sherman

--
To unsubscribe, e-mail: <mailto:poi-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:poi-user-help@;jakarta.apache.org>




--
To unsubscribe, e-mail:   <mailto:poi-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:poi-user-help@;jakarta.apache.org>

Reply via email to