1
2
3
4
5
6 package com.atlassian.core.util;
7
8 import java.util.Comparator;
9 import java.util.Locale;
10
11
12 public class LocaleComparator implements Comparator<Locale>
13 {
14 public int compare(Locale l1, Locale l2)
15 {
16 if (l1 == null && l2 == null)
17 return 0;
18 else if (l2 == null)
19 return -1;
20 else if (l1 == null)
21 return 1;
22
23 String displayName1 = l1.getDisplayName();
24 String displayName2 = l2.getDisplayName();
25
26 if (displayName1 == null)
27 {
28 return -1;
29 }
30 else if (displayName2 == null)
31 {
32 return 1;
33 }
34 else
35 {
36 return displayName1.toLowerCase().compareTo(displayName2.toLowerCase());
37 }
38 }
39 }