[英]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 我正在使用Java Excel API(jxl库)读取Java中excel文件中存在的数据
In my input excel file, I have a column which contains date. 在我的输入excel文件中,我有一列包含日期。 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. 日期可以采用任何格式,例如
dd/mm/yyyy hh:mm
或yy/mm/dd
等。读取文件时,我可以获取任何格式的日期。
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
现在我面临的问题是,输入excel文件中的Date是
9/15/2017 12:30:00 PM
,但是当我使用Java Excel API(jxl库)的getDate()
函数读取date列值时,它将在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
. ((DateCell) icell).getDate()
返回Fri Sep 15 18:00:00 IST 2017
。 I want the same date time value that is present in the excel file. 我想要Excel文件中存在的相同日期时间值。
How should I get the same date time value that is present in the excel file. 我应该如何获得与Excel文件相同的日期时间值。
Once you read the Date
frow excel using getdDate()
you need to format the date using a Formatter. 使用
getdDate()
阅读Date
frow excel后,您需要使用Formatter格式化日期。 Please refer the following URL to understand how to format Date 请参考以下网址以了解日期格式
Change date format in a Java string 更改Java字符串中的日期格式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.