Sahil-Pattni
10/7/2016 - 7:06 AM

formatStr() --- isNumeric()

formatStr() --- isNumeric()

/**
 * Created by Sahil Pattni on 03-Oct-16.
 */
public class MyUtils {

    public static boolean isNumeric(String str) {
            String number = "";

            for (int i = 0; i < str.length(); i++) {
                int x = str.charAt(i);

                if (Character.isDigit(x) || x == '.') {
                    return true;
                }
                else {
                    return false;
                }
            }

            return true;
        }

    public static String formatStr(String str) {
        String capital = str.substring(0,1);
        String rest = str.substring(1, str.length());
        capital = capital.toUpperCase();
        rest = rest.toLowerCase();
        return capital + rest;
    }
}