jexcel api中遇到日期解析问题
我创建了一个名为 tablenew.xls 的文件,其中包含以下代码的日期:
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = (Date)formatter.parse(st[length]);
datecell=new DateTime(tokenNumber,lineNumber,date);
sheet.addCell(datecell);
我在文件中得到的输出为“04-03-11”,即“dd-MM-yy”。 但是,当使用相同的代码将同一日期写入另一个名为 tabletemp.xls 的文件时,我得到的输出类似于 -689881.5。我的困境是,我的程序似乎将这个负值理解为日期。我应该修改我的代码吗?如果是这样,那我该怎么办? 提前致谢
I have created a file named tablenew.xls which has date with following code:
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = (Date)formatter.parse(st[length]);
datecell=new DateTime(tokenNumber,lineNumber,date);
sheet.addCell(datecell);
I am getting the output in my file as "04-03-11" which is "dd-MM-yy".
However when this same date is written to another file named tabletemp.xls with the same code , i get the output as something like -689881.5. My dilemma is that the my program however, seems to understand this negative value as a date. Should i modify my code? if so, then what should i do?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。无论如何,谢谢。与往常一样,日期“04-03-11”显示为
然而,“dd-MM-yy”被 Excel 处理为“MM/dd/yy”。
Jexcel应该研究一下这个问题。他们的日期解析是一个很大的痛苦。
Problem is solved. Thanks anyways. As always, the date "04-03-11" was displayed as
"dd-MM-yy" , was however treated by excel as "MM/dd/yy" .
Jexcel should look into this problem. Their date parsing is a big pain.