poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Louis.Mast...@log-net.com
Subject Re: HSSFCell format/converting problem
Date Thu, 14 Oct 2010 11:24:43 GMT
Are you saying that the time is off by one hour?  I have some code in my 
Excel import that I believe is working, although I may have this issue and 
have not noticed it.

Try this to see if the base value is correct:

Object cellValue = cell.getDateCellValue();
String rc = ((java.util.Date)cellValue).toString();




terraInvader <jenzehss@yahoo.de> 
10/14/2010 07:12 AM
Please respond to
"POI Users List" <user@poi.apache.org>


To
user@poi.apache.org
cc

Subject
HSSFCell format/converting problem







Hi out there,

I got a problem when trying to read an Excel-cell sensefully with 
HSSFCell.
My basic intension here is to combine the date & time cells for a
GregorianCalendar-Object:

http://apache-poi.1045710.n5.nabble.com/file/n3211882/cells.png 

Getting the string value of a date-cell was easy but I fail when trying to
get a useful time-value. The time-cell is Excel-internally formatted with
"custom": 

http://apache-poi.1045710.n5.nabble.com/file/n3211882/format.png 

When switching inside Excel to "General" or "Number" we get a double with
0,75 which is ok for 18:00 representing a fraction of time based on one 
day.

In my code I tried various formatting things, but whatever I do the cell
value "2.9803240299224854" is returned. 

cell.getDateCellValue().toString() or
DateUtil.getJavaDate(cell.getNumericCellValue()).toString()  return

Tue Jan 02 23:31:39 CET 1900.


Does anyone have an idea how to get a String with "18:00:00" or something
that could be processed sensefully?

Thank you very much for your cooperation,

best regards

Jens from Germany.


-- 
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/HSSFCell-format-converting-problem-tp3211882p3211882.html

Sent from the POI - User mailing list archive at Nabble.com.

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



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message