Support for setting Locale for Current Thread
Contents
[
Hide
]
Aspose.Email provides the ability to set the Locale for the current thread. Aspose.Email provides a class CurrentThreadSettings that provides the setLocale method for this purpose. The following code snippet demonstrates the use of the CurrentThreadSettings class to set the current Locale. The snippet fist sets the Locale to an invalid value and then uses the CurrentThreadSettings.setLocale method to set the Locale for the current thread.
Locale defaultLocale = Locale.getDefault();
try {
// set incorrect default Locale
Locale.setDefault(new Locale("en", "RU"));
// set Current Thread Locale
CurrentThreadSettings.setLocale("en-US");
// or
// CurrentThreadSettings.setLocale(new Locale("en", "US"));
PersonalStorage.create(dataDir + "test.pst", FileFormatVersion.Unicode);
} finally {
Locale.setDefault(defaultLocale);
}