Hỗ trợ thiết lập Locale cho Luồng hiện tại
Contents
[
Hide
]
Aspose.Email cung cấp khả năng thiết lập Locale cho luồng hiện tại. Aspose.Email cung cấp một lớp CurrentThreadSettings điều cung cấp setLocale phương thức cho mục đích này. Đoạn mã dưới đây minh họa việc sử dụng CurrentThreadSettings lớp để đặt Locale hiện tại. Đoạn mã ban đầu đặt Locale thành giá trị không hợp lệ và sau đó sử dụng CurrentThreadSettings.setLocale phương thức để đặt Locale cho luồng hiện tại.
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);
}