0

I am using Java Excel API (jxl library) for reading data present in excel file in Java

In my input excel file, I have a column which contains date. Date can be in any format like say dd/mm/yyyy hh:mm or yy/mm/dd etc. While reading the file, I can get date in any format.

Right now the issue I am facing is, Date in the input excel file is 9/15/2017 12:30:00 PM, but when I am reading the date column value using getDate() function of Java Excel API (jxl library), it is returning me modified timestamp value in the i.e. Fri Sep 15 18:00:00 IST 2017

Date inputdate = ((DateCell) icell).getDate();

((DateCell) icell).getDate() returns Fri Sep 15 18:00:00 IST 2017. I want the same date time value that is present in the excel file.

How should I get the same date time value that is present in the excel file.

Jobin
  • 5,610
  • 5
  • 38
  • 53
Reena Upadhyay
  • 1,977
  • 20
  • 35

1 Answers1

0

Once you read the Date frow excel using getdDate() you need to format the date using a Formatter. Please refer the following URL to understand how to format Date
Change date format in a Java string

Community
  • 1
  • 1
Jobin
  • 5,610
  • 5
  • 38
  • 53
  • there is not single format used. User can provide date in any format in the excel sheet. SO with the given date, how can I know its format? I would request to share a example relevant to my question. The provided link does fit in my scenario. – Reena Upadhyay Dec 06 '16 at 11:50
  • try this and see what is the value you are getting cell.getCellFormat().getFormat().getFormatString(); – Jobin Dec 06 '16 at 12:02