简体   繁体   中英

how to get date timestamp value from excel sheet using Java Excel library

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 ie 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM