Free Support Forum -

How can I parse dates?

I’m evaluating this product and I’m having problems with date formats.

Actually, what I need to do is receive a .docx file and export to .pdf. This process goes fine but for document headers I have a timestamp and using Aspose.words for java I get this format: Version 9/13/2018 3:08:00 PM

However, in my previous implementation (without Aspose.words) I had this: Version 13.09.2018 09:22:00.

I have tried 2 different ways to try to get the desired format, the first was change system’s locale, produce pdf file, restore original locale. The second was to get all Run nodes in the document and change the locale. Both did change nothing.

My sample codes are:

Document doc = new Document(document.getInputStream());
NodeCollection<Run> collection = doc.getChildNodes(NodeType.RUN, true);
for (Run run : collection) {
    run.getFont().setLocaleId(1031); // From MS - German Germany de-de 1031 
}, SaveFormat.PDF);


Locale current = Locale.getDefault();
Locale.setDefault(new Locale("de", "DE"));
Document doc = new Document(document.getInputStream());, SaveFormat.PDF);

Is there something I’m missing?


Please ZIP and upload your simplified input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. We will investigate the issue on our end and provide you more information.

Attached there’s a file with docx and pdf files, as well an image with desired output.

Thanks so far.


You can try following methods to workaround this problem:

Code 1:

Locale.setDefault(new Locale("de", "DE"));
Document doc = new Document("D:\\aspose_sample\\aspose_sample.docx");

Code 2:

Document doc = new Document("D:\\aspose_sample\\aspose_sample.docx");

PdfSaveOptions opts = new PdfSaveOptions();
opts.setUpdateFields(false);"D:\\aspose_sample\\18.9-UpdateFields-false.pdf", opts);

Hope, this helps.


Code 1 did exactly what I needed. Thanks so far for your help :slight_smile: