List of utility methods to do String Title Case
String | titlecase(String str) titlecase return (Character.toTitleCase(str.charAt(0)) + str.substring(1));
|
String | titleCase(String txt) Convert the first character and every character that follows a space to uppercase. StringBuffer buf = new StringBuffer(txt); int len = buf.length(); buf.setCharAt(0, Character.toUpperCase(buf.charAt(0))); for (int i = 1; i < len; i++) { if (buf.charAt(i - 1) == ' ') { buf.setCharAt(i, Character.toUpperCase(buf.charAt(i))); return buf.toString(); |
String | titleCasedName(T instance) title Cased Name StringBuilder name = new StringBuilder(instance.name().toLowerCase()); name.setCharAt(0, Character.toUpperCase(name.charAt(0))); for (int i = 0; i < name.length(); i++) { if (name.charAt(i) == '_') { name.setCharAt(i, ' '); name.setCharAt(i + 1, Character.toUpperCase(name.charAt(i + 1))); return name.toString(); |
String | titleCaseTruncate(String s, int maxlen) title Case Truncate return transform(s, true, false, maxlen);
|
int | toTitleCase(final int chr) Convert a character to title case return Character.toTitleCase(chr);
|
String | toTitleCase(final String input) Capitalizes all words in a string. if (input == null || input.isEmpty()) throw new IllegalArgumentException("Input cannot be null or empty!"); final String[] words = input.trim().split(" "); final StringBuilder sb = new StringBuilder(); for (final String word : words) { sb.append(Character.toUpperCase(word.charAt(0))).append(word.substring(1)).append(' '); return sb.toString().trim(); ... |
String | toTitleCase(final String inStr) Converts the string to title case. if ((inStr == null) || (inStr.length() < 1)) { return ""; } else { final int nLen = inStr.length(); if (nLen == 1) { return inStr.toUpperCase(); boolean blankFound = true; ... |
String | toTitleCase(final String inStr, final boolean putRestInLC) Convert a string to title case. if ((inStr == null) || (inStr.length() < 1)) { return ""; } else { final int nLen = inStr.length(); if (nLen == 1) { return inStr.toUpperCase(); boolean blankFound = true; ... |
String | toTitleCase(final String s) Converts an input string into title case, capitalizing the first character of every word. final StringBuilder sb = new StringBuilder(s); return toTitleCase(sb).toString(); |
String | toTitleCase(final String text) to Title Case if (text == null) { return null; if ("".equals(text)) { return ""; return text.substring(0, 1).toUpperCase() + text.substring(1); |