Java Reference
In-Depth Information
list1.stream().forEach((range) -> {
System.out.println("Range:" + range.getRange());
});
ArrayList<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);
});
Here are the results:
Range:en
Range:en-ca
The following is the matching list of locales:
en
How It Works
Methods have been added to the java.util.Locale class in Java 8 that allow you
to filter Locale instances or language tags based on a supplied priority list in
List<Locale.LanguageRange> format. The filtering mechanism is based on
RFC 4647. The following list contains a short summary of these filtering methods:
filter(List<Locale.LanguageRange>, Collec-
tion<Locale>)
filter(List<Locale.LanguageRange>,
Collection<Locale>, Locale.FilteringMode)
(Returns matching list of Locale instances)
filterTags(List<Locale.LanguageRange>, Collec-
tion<String>)
Search WWH ::




Custom Search