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:
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
@alexey.noskov Our code framework does not allow passing any datatypes other than String to the merge field execution. When we pass the String value with the timezone component to it (10/28/2024 08:47 AM CST), it defaults the timestamp to 12:00 AM giving us October 28, 2024 12:00 AM instead of October 28, 2024 08:47 AM. When we don’t pass the timezone component in the string, it shows us the timestamp correctly. For example, when we pass 10/28/2024 08:47 AM, it gives us October 28, 2024 08:47 AM in the resulting PDF.
Is there a way to only show timestamp for a date time field? For example can it be split it such that we will get the date and timestamp separately For example - “AuthRequestDateTime” @ "MMMM d, yyyy“ “AuthRequestDateTime” @ "h:mm AM/PM ‘CST’“. Currently the mergefield is not processing the timestamp correctly. Or any other suggestion?
Thanks
@jcash_casenetllc_com
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-27602
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The issues you have found earlier (filed as WORDSNET-27602) have been fixed in this Aspose.Words for Java 25.1 update.