![](/img/trans.png)
[英]How to read the exact date format from Excel cell having formula field with Apache POI?
[英]Unable to read excel cell value having date field using Java
我將數據以日期字段作為列之一導出到excel工作表中。 例如我將數據導出為28/10/2018 12:32。 我正在編輯日期。
導入日期后,它會給我日期的數字,例如123342.23424。 我已經經歷過了,但是這沒有給出我導出的日期格式。 https://stackoverflow.com/questions/3148535/how-to-read-excel-cell-having-date-with-apache-poi
如果從前端獲取原始單元格日期值,則apache poi提供了一個util date類:
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.poi.ss.usermodel.DateUtil;
public class Main {
public static void main(String[] args) {
Date d = DateUtil.getJavaDate(42064.625);
SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
System.out.println(f.format(d));
}
}
01/03/2015 15:00:00
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.