Java examples for Internationalization:Locale
Use Locale.filter method to filter locale
import java.util.ArrayList; import java.util.List; import java.util.Locale; public class Main { public static void main(String[] args) { String localeTags = Locale.ENGLISH.toLanguageTag() + "," + Locale.CANADA.toLanguageTag(); List<Locale.LanguageRange> list1 = Locale.LanguageRange.parse(localeTags); list1.stream().forEach((range) -> { System.out.println("Range:" + range.getRange()); });/*from w w w .ja va2 s .com*/ List<Locale> localeList = new ArrayList<>(); localeList.add(new Locale("en")); localeList.add(new Locale("en-JP")); List<Locale> tags1 = Locale.filter(list1, localeList); System.out.println("The following is the matching list of Locales:"); tags1.stream().forEach((tag) -> { System.out.println(tag); }); } }