Java Locale getUnicodeLocaleAttributes() 方法



描述

Java Locale getUnicodeLocaleAttributes() 方法返回與此區域設定關聯的 Unicode 區域設定屬性集,如果沒有屬性則返回空集。返回的集合是不可修改的。

宣告

以下是 java.util.Locale.getUnicodeLocaleAttributes() 方法的宣告

public Set<String> getUnicodeLocaleAttributes()

引數

返回值

此方法返回屬性集。

異常

從區域設定獲取 Unicode 區域設定屬性示例

以下示例顯示了 Java Locale getUnicodeLocaleAttributes() 方法的用法。我們建立一個具有電子郵件屬性的區域設定,該屬性使用 getUnicodeLocaleAttributes 獲取並列印。

package com.tutorialspoint;

import java.util.Locale;

public class LocaleDemo {
   public static void main(String[] args) {

      // create a new locale
	   Locale locale = Locale.forLanguageTag("de-DE-u-email-co-phonebk-x-linux");

      // print this locale
      System.out.println("Locale:" + locale);

      // print the set of attributes of this locale
      System.out.println("Attributes:" + locale.getUnicodeLocaleAttributes());
   }
}

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

Locale:de_DE_#u-email-co-phonebk-x-linux
Attributes:[email]
java_util_locale.htm
廣告