Java Word date number format internationalization

We have templates that could be used by different European users.
We are hoping that the numbers and dates merged into a template are displayed in the locale of the user.
The XML we supply has dates in ISO8601 and numbers are xs:decimal, i.e. no thousand separator and decimal is a full stop.

There are various threads on this but none have reached a conclusion.

We can make it work by:
1 Setting the default Locale
2 Setting the CultureInfo of each field
3 Changing the number format for the Locale

There are issues:
1 Setting Locale changes it for the VM, so we can only merge one document at a time. And its the only application deployed to the server.
2 The CultureInfo class is named zz5J? This suggests to me we should not be using it.
3 Creating a CultureInfo from a Locale means a conversion from de_DE to de-DE? Is there a better way than strings
4 Word date formats replace the language but not the order of the date parts. We were thinking of replacing the date format in a IFieldMergeingCallback

This seems like quite a lot to do, some of it word related.
Are we on the right track?

We are using aspose-words-19.12-jdk17.jar

@mleake You can use CurrentThreadSettings class to specify locale, which will be used for formatting values upon executing mail merge. For example see the following code:

Locale currentLocale = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.GERMANY);

// Execute your code here.

CurrentThreadSettings.setLocale(currentLocale); 

Thanks for the prompt reply.

That worked.
Excellent work.

1 Like