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);
So we have to set this globally. This is executed server side, there is no way we can set this locally so we can provide different local depending on the user connected ?
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.
You can also make use of FieldOptions.FieldUpdateCultureSource property to specify what culture to use to format the field result. Please note that by default, the culture of the current thread is used and this setting affects only date/time fields with @ format switch.
For example, the following code snippet shows how to specify where the culture used for date formatting during field update and mail merge is chosen from.
// 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() });
Hope this helps you. Please let us know if you have any more queries.
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");
// 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.