We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

\@ MM/dd/yyyy format is not working while localization is use

I am using aspose-words-22.12 version.

\@ MM/dd/yyyy format is not working while localization is use.

Local is UK and date format is dd/MM/yyyy and I would like to convert in MM/dd/yyyy format then it will not work as expected.

Example :
date_c : 03/04/2017 (dd/MM/yyyy - 03 April 2017)
while applying \@ MM/dd/yyyy in word document its print as a 03/04/2017

Following is my code

MailMerge merge = doc.getMailMerge() ;
DataSet dataSet = new DataSet() ;
dataSet.readXml( xmlFilepath ) ; 
merge.executeWithRegions(dataSet);
doc.save("E:\\\\sample letter with dates\\\\sample letter with dates2.docx") ;

@akondewar Unfortunately, I cannot reproduce the problem. I have used the following simple code for testing:

Locale current = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.UK);

// Create a simple template with merge fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.write("Date format 'MM/dd/yyyy': ");
builder.insertField("MERGEFIELD date \\@ MM/dd/yyyy");
builder.writeln();

builder.write("Date format 'dd/MM/yyyy': ");
builder.insertField("MERGEFIELD date \\@ dd/MM/yyyy");

// Execute mail merge.
Date date = new GregorianCalendar(2017, 4 - 1, 3).getTime();
doc.getMailMerge().execute(new String[] { "date" }, new Object[] { date });

doc.save("C:\\Temp\\out.docx");

CurrentThreadSettings.setLocale(current);

Both date formats works fine on my side. The output is the following:

Date format 'MM/dd/yyyy': 04/03/2017
Date format 'dd/MM/yyyy': 03/04/2017

Hi,
Thanks for valuable reply. But we are using com.aspose.words 15.11.0.0 jar.

There may be regression impact if I update the JAR, so it cannot be done at this time.

We are giving date format in the word document.

We need solution for this version.

Mixed date format is used while using German Locale.
date format is '\@ MM.dd.yyyy'

it’s generate 09.01.2021 , 12/24/2022 , 24/11/2022 etc.

@akondewar Could you please attach your sample input, output and expected output documents along with code that will allow us to reproduce the problem? We will check the issue and provide you more information.
Please note, we do not provide fixes for old versions of Aspose.Words, all fixes and improvements are delivered with new versions of Aspose.Words. 15.11 version of quite old, it has been released about 7 years ago, so I would advice you to update to the newer version.