code: public static String capitalize(final String text)
      {
          String tmp = text.trim();
          int len = tmp.length();
  
          if (len == 0)
              return text;
  
          StringBuilder sb = new StringBuilder(len);
  
          for (int i = 0; i < len; i++)
          {
              if (Character.isLetter(tmp.charAt(i)))
              {
                  Locale locale = currentLocale();
                  int lc = i + 1;
  
                  if (i > 0)
                  {
                      sb.append(tmp.substring(0, i));
                  }
  
                  sb.append(tmp.substring(i, lc).toUpperCase(locale));
                  sb.append(tmp.substring(lc).toLowerCase(locale));
  
                  break;
              }
          }
  
          return sb.length() == 0 ? tmp : sb.toString();
      }
docs: <p>
  Capitalizes the given text smartly.
  </p>
  
  @param text
  String to be capitalized
  @return capitalized string