Java String Upper Case toUpperCase(String text)

Here you can find the source of toUpperCase(String text)

Description

to upper case like XXX_XXX_XXX

License

Apache License

Parameter

Parameter Description
text a parameter

Declaration

public static String toUpperCase(String text) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*w w  w . ja v  a  2s . c  o  m*/
     * to upper case like XXX_XXX_XXX
     * 
     * @param text
     * @return
     */
    public static String toUpperCase(String text) {
        if (text != null && text.length() > 0) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < text.length(); i++) {
                char c = text.charAt(i);
                if (i != 0 && Character.isUpperCase(c)) {
                    sb.append("_");
                }
                sb.append(Character.toUpperCase(c));
            }
            return sb.toString();
        }
        return text;
    }
}

Related

  1. toUpperCase(String str)
  2. toUpperCase(String str)
  3. toUpperCase(String str)
  4. toUpperCase(String string)
  5. toUpperCase(String string)
  6. toUpperCase(String text)
  7. toUpperCase(String text)
  8. toUpperCase(String value)
  9. toUpperCase(String value)