From 5b10f73c1f695542ee2d878a591362d7f274b89a Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Wed, 26 Mar 2014 14:08:43 +0100 Subject: [PATCH] String collation, Java example --- .../src/de/example/collation/CollationExample.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Allgemeines/UNICODECollation/src/de/example/collation/CollationExample.java diff --git a/Allgemeines/UNICODECollation/src/de/example/collation/CollationExample.java b/Allgemeines/UNICODECollation/src/de/example/collation/CollationExample.java new file mode 100644 index 0000000..1d728b1 --- /dev/null +++ b/Allgemeines/UNICODECollation/src/de/example/collation/CollationExample.java @@ -0,0 +1,29 @@ +package de.example.collation; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +public class CollationExample { + + + public static void main(final String[] args) { + final String[] words = {"cote", "coté", "côte", "côté"}; + + final List wordsListES = new ArrayList(Arrays.asList(words)); + final List wordsListFR = new ArrayList(Arrays.asList(words)); + + final Collator es_ESCollator = Collator.getInstance(new Locale("es","ES")); + final Collator fr_FRCollator = Collator.getInstance(Locale.FRANCE); + + Collections.sort(wordsListES, es_ESCollator); + Collections.sort(wordsListFR, fr_FRCollator); + + System.out.println("Words list ES: " + wordsListES); + System.out.println("Words list FR: " + wordsListFR); + } + +} -- 2.1.4