Matching and Filtering Locales with locale matching and filtering methods in the java.util.Locale class - Java Internationalization

Java examples for Internationalization:Locale

Description

Matching and Filtering Locales with locale matching and filtering methods in the java.util.Locale class

Demo Code

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class Main {

    public static void main(String[] args) {
      List<Locale.LanguageRange> list1 = Locale.LanguageRange.parse("ja-JP, en-US");
      list1.stream().forEach((range) -> {
          System.out.println("Range:" + range.getRange());
      });/*from  w w w.  j a  v  a  2s . c o m*/
      List<String> localeList = new ArrayList<>();
      localeList.add("en-US");
      localeList.add("en-JP");

      List<String> tags1 = Locale.filterTags(list1, localeList);
      System.out.println("The following is the filtered list of Locales:");
      tags1.stream().forEach((tag) -> {
          System.out.println(tag);
      });
    }

}

Related Tutorials