Speculation: It could also be floating point precision.

On 6/4/03 7:06 PM, "Chris Cheshire" <[EMAIL PROTECTED]> wrote:

> George,
> 
> I don't think this is POIs problem. I have experienced the same thing
> when using Calendars in my software. I tried to get a date as close to
> the end of the day as possible, but if I didn't set the milliseconds to
> 0 it would magically wrap the date over to the next day. I found that a
> SimpleDateFormat was displaying a different date to what was actually
> displayed from a Calendar.toString(). My guess is when POI set the date
> the value it retrieved from the Calendar/Date was already incremented.
> This was all on J2SE 1.4.1
> 
> HTH
> 
> Chris
> 
> George Papastamatopoulos wrote:
> 
>> Hey thanks for the reply.
>> 
>> Actually was able to narrow the problem down further.
>> 
>> Turns out the dates I was using in my application were all set to the last
>> millisecond of the day eg 23:59:59:999.  Looks like excel was rounding this
>> value up to the nearest second, thus pushing the value displayed in the cell
>> to the next day.  I think (although my understanding of excel is limited)
>> this would be due to the fact that excel understands only hours, minutes and
>> seconds?
>> 
>> george
>> 
>> -----Original Message-----
>> From: Danny Mui [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, 5 June 2003 12:36 AM
>> To: POI Users List
>> Subject: Re: Dates, Dates and more dates.
>> 
>> 
>> Yeah, I know the dates are a little off at the moment, and is related
>> to  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19792.  Currently
>> working on other parts of HSSF but I will try to address it within the
>> "soon" timeframe.
>> 
>> IF you want to give it a stab, you can look at the HSSFDateUtil and
>> determine where it strays.  Basically excel stores date in double
>> format, so make sure the DateUtil generates the correct double values
>> for known dates.
>> 
>> danny
>> 
>> George Papastamatopoulos wrote:
>> 
>>  
>> 
>>>> Hi
>>>> 
>>>> Im experiencing some really wierd and frustrating behaviour when dealing
>>>> with dates.
>>>> 
>>>> Whenever I generate a spreadsheet with dates and then open up the
>>>> spreadsheet, the value displayed in the cell is always one day ahead of
>>>> the value displayed in the formula bar (the formula bar always displays
>>>> the correct date).  What's wierd is that when I click into the cell edit,
>>>> and then hit enter, the correct date is then displayed in the cell.
>>>> 
>>>> I've searched the archives and have seen similar postings relating to 'how
>>>> to read dates from excel', but havnt come across any solutions.
>>>> 
>>>> I've tried all sorts of combinations and permutations of cell styles,
>>>> formats etc, but have been unable to solve the problem.
>>>> 
>>>> If anyone has suggestions, they would be much appreciated.  I've pasted in
>>>> the latest code snippet below.
>>>> 
>>>> Cheers
>>>> george
>>>> 
>>>> ....
>>>> 
>>>> HSSFCellStyle cellStyle = wb.createCellStyle();
>>>> HSSFDataFormat format = wb.createDataFormat();
>>>> 
>>>> cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
>>>> cell.setCellStyle(cellStyle);
>>>> 
>>>> Date myDate = myObject.getTheDate();
>>>> 
>>>> cell.setCellValue(myDate);
>>>> cell.setCellValue(HSSFDateUtil.getExcelDate(myDate));
>>>> 
>>>> /**
>>>> * Also tried the following and a bunch of other things
>>>> */
>>>> //  cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
>>>> //  cell.setCellValue(myDate);
>>>> ....
>>>> 
>>>> __________________________
>>>> George Papastamatopoulos
>>>> 
>>>> Lawlex Compliance Solutions
>>>> phone: +61 3 9278 1182
>>>> email: [EMAIL PROTECTED]
>>>> __________________________
>>>> 
>>>>   
>>>> 
>>>>      
>>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>> 
>>> 
>>> 
>>>    
>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>>  
>> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
Andrew C. Oliver
http://www.superlinksoftware.com/poi.jsp
Custom enhancements and Commercial Implementation for Jakarta POI

http://jakarta.apache.org/poi
For Java and Excel, Got POI?


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to