Format Date (time zone) as MM/dd/yyyy String using Merge Field Switch in Word Document using Java

Hello,
I am passing to Aspose.Words a date string value with a timezone. A sample date would be: “01/08/2020 08:47 AM EST”
The field in the Word template is defined as the following: { MERGEFIELD “AuthRequestDateTime” @ “MM/dd/yyyy” }

The generated pdf document is showing the date string without applying the switch specified in the template to format the date. It shows “01/08/2020 08:47 AM EST”, but it should show “01/08/2020” instead.

I have tested the switch in Word without using Aspose.Words, and the switch is applied correctly. Is this a bug in the library? I am using version 15.5.0.

I have attached a sample Word document with an access DB with the dates where this can be tested.

Thanks

sample letter with dates.zip (15.2 KB)

@danimas,

After an initial test with the licensed latest (20.6) version of Aspose.Words for .NET, we were unable to reproduce this issue on our end. Please see the following output DOCX document generated on our end:

We used the following simple C# code to produce above output:

Document doc = new Document("E:\\sample letter with dates\\sample letter with dates.docx");

doc.MailMerge.Execute(new string[] { "AuthRequestDateTime" },
                            new string[] { "01/08/2020 08:47 AM EST" });

doc.Save("E:\\sample letter with dates\\mail-merged document produced using 20.6.docx");

So, we suggest you please upgrade to the latest version. Hope, this helps.

Thanks for your answer. I am using Aspose.Words for Java, not .NET. I will try anyway with the latest version for Java, which I think it is 20.5, and see if it works. Thank you.

@danimas,

We have also checked the scenario with the 20.5 version of Aspose.Words for Java on our end; it also produces the correct output. Here is the Java code that we tested on our end:

Document doc = new Document("E:\\sample letter with dates\\sample letter with dates.docx");

doc.getMailMerge().execute(new String[] { "AuthRequestDateTime" },
                        new String[] { "01/08/2020 08:47 AM EST" });

doc.save("E:\\sample letter with dates\\mail-merged document produced using awjava-20.6.docx");

Thank you so much. I will test with 20.5 as soon as I can and let you know if that solved my problem.

Hello,
I just wanted to confirm that I tested the issue with Aspose.Words for Java 20.5 and it is working correctly. Thank you for your support.

Regards,
Daniel Mas

@danimas,

Thanks for your feedback. It is great that the 20.5 version of Aspose.Words for Java resolves the issue on your end. Please let us know any time you may have any further queries in future.