Not showing correct Time Stamp

Hi,

We are experiencing an issue where it is not showing or displaying correct timestamp when passing date string value with a timezone (10/28/2024 08:47 AM EDT) and added a format switches to the AuthRequestDateTime field using “AuthRequestDateTime” @ "MMMM d, yyyy h:mm AM/PM ‘CST’“
Seems the switch format specified in the template to override the format is no longer working . Testing with Aspose 21.4 version.

I extracted the code working with the template into a minimal console application and able to reproduce the problem with the template.

Sample console application: Aspose_SEA-6388.zip (5.6 MB)

Template: Sample_Date1.docx - Placed in the above zip file

Instruction to run the sample console application:

  • Go to the Main.java,

  • Verify the ‘fileTemplate’ path of the template.

  • Run the MainTest.main().

Is there a way to correct that in the letter template standpoint or in the code standpoint and please let us know the expected behavior as per the Aspose product.

Thank you

@jcash_casenetllc_com Could you explain what is your expected output? The date string provided as value is parsed to Date object and formatted with the format switch specified in the field.

Document doc = new Document("C:\\Temp\\in.docx");
MailMerge mailMerge = doc.getMailMerge();
// process field tags
mailMerge.execute(new String[] { "AuthRequestDateTime" }, new String[] { "10/28/2024 08:47 AM EDT" });
doc.updateFields();
doc.save("C:\\Temp\\out.pdf");

in.docx (43.5 KB)
out.pdf (38.3 KB)

HI @alexey.noskov ,

As per the above example, we are passing the date as 10/28/2024 08:47 AM EDT but pdf showing as ‘October 28, 2024 12:00 AM CST’, where displays the timestamp as 12:00 instead of 8:47, which is incorrect.
Screenshot:

Expected Output: In the PDF generated letter it should show correct Time stamp (Hours and Minutes)
Example: it should show as October 28, 2024 08:47 AM CST in the PDF.

@jcash_casenetllc_com In your case you should parse the date/time value using explicit date/time format. For example see the following code:

Document doc = new Document("C:\\Temp\\in.docx");
MailMerge mailMerge = doc.getMailMerge();
    
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm a z", Locale.ENGLISH);
String dateInString = "10/28/2024 08:47 AM EDT";
Date date = formatter.parse(dateInString);
        
// process field tags
mailMerge.execute(new String[] { "AuthRequestDateTime" }, new Object[] { date });
doc.updateFields();
doc.save("C:\\Temp\\out.pdf");

out.pdf (38.7 KB)

@alexey.noskov Thanks for the update. We would appreciate it if you could inform us of the workaround or fix from a template perspective.

Thank you

@jcash_casenetllc_com I am afraid, there is no way to achieve this in the template.

Thank you so much @alexey.noskov

1 Like