Android examples for java.lang:StringBuilder
capitalize string via StringBuilder and substring
import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static String capitalize(String str) { if (str == null || str.length() == 0) { return str; }//from w ww.j a va 2s. com StringBuilder sb = new StringBuilder(str.length()); sb.append(Character.toUpperCase(str.charAt(0))); sb.append(str.substring(1)); return sb.toString(); } }