poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Papastamatopoulos <George.Papastamatopou...@lawlex.com.au>
Subject RE: Dates, Dates and more dates.
Date Wed, 04 Jun 2003 23:10:23 GMT
I think your right Chris.  

As far as I can see, POI is handling the date value fine.  Remember that I'm
going from POI -> Excel.  I'm pretty sure that excel is for some reason or
another not accurately handling the double returned from
HSSFDateUtil.getExcelDate().

george

-----Original Message-----
From: Chris Cheshire [mailto:ccheshire@bigredwire.com]
Sent: Thursday, 5 June 2003 9:07 AM
To: POI Users List
Subject: Re: Dates, Dates and more dates.


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:danny@muibros.com]
>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: georgep@lawlex.com.au
>>>__________________________
>>>
>>>   
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>>
>> 
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>
>  
>




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

Mime
View raw message