将日期的数字表示形式转换为java中的Date [英] Converting Number representation of Date in excel to Date in java

查看:463
本文介绍了将日期的数字表示形式转换为java中的Date的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在excel中有日期列,但是当我读入我的java应用程序时,我得到的值就是数字



示例



Excel日期

  1/1/2013 

正如

  41275.00 

如何在我的Java应用程序中转换号码?

解决方案

Apache POI有一些实用程序 http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DateUtil.html ,特别是 http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/ DateUtil.html#getJavaDate(double)



注意Excel将日期存储为自1900年以来的天数(加上小数天)(在某些情况下,它可以来自1904年)。请参阅 http://support.microsoft.com/kb/180162


I have date column in excel, but when I'm reading in my java application I'm getting value as number

Example

Excel Date

1/1/2013

Am getting as

41275.00

How to convert number to date in my Java application?

解决方案

Apache POI has some utilities for that http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DateUtil.html, notably http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DateUtil.html#getJavaDate(double)

Note Excel stores dates as the number of days (plus fractional days) since 1900 (and in some cases it can be from 1904). See http://support.microsoft.com/kb/180162.

这篇关于将日期的数字表示形式转换为java中的Date的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆