开发者

How to set up a correct creation date with PDFBox?

开发者 https://www.devze.com 2023-03-16 08:07 出处:网络
I\'m learning how to generate PDF with PDFBox. So far, I managed to create the document and to modify basic meta data.

I'm learning how to generate PDF with PDFBox. So far, I managed to create the document and to modify basic meta data.

I do have a problem with the date of creat开发者_运维问答ion, though. I tried many things, this being the most logical one:

//My PDDocument is called "document".
PDDocumentInformation info = document.getDocumentInformation();
info.setCreationDate(Calendar.getInstance());

The result, when right-clicking on the generated PDF and choosing "properties" is mar 28 jun 2011 12:28:36 CEST. (mar stands for "mardi", Tuesday in French). My problem is that the correct time should be 12:28:36 GMT+1.

When I print System.out.println(Calendar.getInstance());, it returns (...)zone=sun.util.calendar.ZoneInfo[id="Europe/Zurich",(...) (Full content on demand), which is correct!

So, where is the problem?


There is no problem in you code. If you run it in france during dst, local time should be GMT+2. And GMT+2 is same as CEST.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号