Hi,
Hi Hugo,
Thanks for your inquiry. Please set default locale for the specified category using Locale.setDefault to get the desired output.
Locale.setDefault(new Locale(“fr”, “FR”));
Document doc = new Document(MyDir + “in.docx”);
You may also use FieldOptions.FieldUpdateCultureSource property to specify what culture to use to format the field result. FieldUpdateCultureSource enumeration indicates what culture to use during field update.
CurrentThread : The culture of the current execution thread is used to update fields.
FieldCode : The culture specified in the field formatting properties via language setting is used.
Following code snippet shows how to use FieldUpdateCultureSource enumeration as FieldCode.
Document doc = new Document(MyDir + “in.docx”);
doc.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);
Thanks Tahir.
Hi Hugo,
Thanks for your inquiry. You need to set the Locale according to your template document. Locale.setDefault sets the default locale for the specified Category for this instance of the Java Virtual Machine. Please set the Locale where you are executing the Aspose.Words code.
doc.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);<o:p></o:p>
doc.getMailMerge().execute(new String[] { "quot_createddate" }, new Object[] { new java.util.Date() });
Thanks Tahir.
Hi Hugo,
Thanks for your inquiry. Please execute the following code example with FieldUpdateCultureSource as CurrentThread and FieldCode to check the difference. We have attached sample input and output documents with this post for your kind reference. Please set the language of mail merge field according to your requirement from Review tab in Language section.
Document doc = new Document(MyDir + “in.docx”);<o:p></o:p>
// Set the culture used during field update to the culture used by the field.
doc.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);
doc.getMailMerge().execute(new String[] { "quot_createddate" }, new Object[] { new java.util.Date() });
If you still face problem, please share your input and expected output document here for our reference. We will then provide you more information about your query.