Dukungan untuk mengatur Locale untuk Thread Saat Ini

Contents
[ ]

Aspose.Email menyediakan kemampuan untuk mengatur Locale untuk thread saat ini. Aspose.Email menyediakan sebuah kelas CurrentThreadSettings yang menyediakan setLocale metode untuk tujuan ini. Potongan kode berikut menunjukkan penggunaan CurrentThreadSettings kelas untuk mengatur Locale saat ini. Potongan kode pertama mengatur Locale ke nilai tidak valid dan kemudian menggunakan CurrentThreadSettings.setLocale metode untuk mengatur Locale untuk thread saat ini.

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);
}