Example
Category
Globalization : Locale Handling

Name
Avoid using locale names as string literals

Explanation
The names of locales in Java are not fixed and may be changed in the future. However, each locale is represented by a unique Locale object that will be backwards compatible. Use the Locale object instead of the string with the locale name.

Solution
Use the Locale object as a parameter in methods that are locale-sensitive.

public static final String CHINESE_LOCALE_STRING = "CHINESE"; //$NON-NLS-1$

private static void processEnglishString(String str) {
// process string in US locale
}

private static void processChineseString(String str) {
// process string in CHINESE locale
}
public static void processString(String str, Locale locale){
if (Locale.CHINA.equals(locale)){
processChineseString(str);
}else {
processEnglishString(str);
}
}


public static void main(String[] args) {
String str = "\u4e1c\u897f\u5357\u5317\u4e2d";//$NON-NLS-1$
if ( CHINESE_LOCALE_STRING.equals( args[0] ) ){
processString( str, Locale.CHINA );
}else {
processString( str, Locale.US );
}
}