public static int toDecimal(String binaryNumber) {
    if (binaryNumber.isEmpty() || binaryNumber == null) {
        return 0;
    } else {
        int x = 0;
        int result = 0;
        char numberPlace;
        for (int i = 0; i < binaryNumber.length(); i++) {
            numberPlace = binaryNumber.charAt(i);
            x = Character.getNumericValue(numberPlace);
            x = x * (int) Math.pow(2, (binaryNumber.length() - i - 1));
            result += x;
        }
        return result;
    }
}