public static String toUpperCase(String s,Locale locale){
  if (s == null) {
    return null;
  }
  StringBuilder sb=null;
  for (int i=0; i < s.length(); i++) {
    char c=s.charAt(i);
    if (c > 127) {
      if (locale == null) {
        locale=Locale.getDefault();
      }
      return s.toUpperCase(locale);
    }
    if ((c >= 'a') && (c <= 'z')) {
      if (sb == null) {
        sb=new StringBuilder(s);
      }
      sb.setCharAt(i,(char)(c - 32));
    }
  }
  if (sb == null) {
    return s;
  }
  return sb.toString();
}

public static String toUpperCase ( String s , Locale locale ) { if ( s == null ) { return null ; } StringBuilder sb = null ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c > 127 ) { if ( locale == null ) { locale = Locale . getDefault ( ) ; } return s . toUpperCase ( locale ) ; } if ( ( c >= 'a' ) && ( c <= 'z' ) ) { if ( sb == null ) { sb = new StringBuilder ( s ) ; } sb . setCharAt ( i , ( char ) ( c - 32 ) ) ; } } if ( sb == null ) { return s ; } return sb . toString ( ) ; }
converts all of the characters in the string to upper case , based on the locale .
