Parsing Excel Date with POI - JXLS

Just a quick post from me here. I couldn't find  any resources on the internet, I couldn't remember how I found this solution. Here's the scenerio.

When you try to parse and Excel sheet using JXLS, unless your Excel sheet column is formatted in General, you wouldn't be able to get the actual date format like mm/dd/yyyy. If your column is formatted to have a Date field, once you parse in JXLS you will get something like

39505 

All you have to do is pass that to  HSSFDateUtil (org.apache.poi.hssf.usermodel.HSSFDateUtil)'s , getJavaDate method like this...

HSSFDateUtil.getJavaDate( Double.parseDouble("39505") );

And it will give you a Date object that has the value 

Wed Feb 27 00:00:00 CST 2008

Remember that JXLS is just a wrapper for POI. POI is the real Excel Framework so you could still use POI classes. 

Busy busy busy

Published Tuesday, March 25, 2008 1:33 AM by lamia
Filed under: ,

Comments

# re: Parsing Excel Date with POI - JXLS

Tuesday, March 25, 2008 7:19 PM by lamia

Haven't tried. My team used JXLS even before I came into the project. :)

# re: Parsing Excel Date with POI - JXLS

Wednesday, June 11, 2008 2:16 PM by karthik

Good. Thank you. Exactly what I required.

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: