How to check IBAN number with Apache IBANCheckDigit?

In my Android application, I am trying to check if the bank account number is IBAN. This can be done using Apache IBANCheckDigit . Now I will try to do this:

IBANCheckDigit a = new IBANCheckDigit();
try {
    String checkDigit = a.calculate("MY_IBAN_NUMBER_HERE");
    Boolean b = a.isValid(checkDigit);
    Log.e("isValid: ", b.toString());
} catch (CheckDigitException e) {
    Log.e(this, "THIS IS AN ERROR");
}

This, however, always prints false. Even if I insert my own (correct) IBAN, it also gives false.

Does anyone know how to use this Apache IBANCheckDigit? Any advice is appreciated!

+4
source share
2 answers

To check if IBAN check digits are valid, you should use only the method isValid:

Boolean b = a.isValid("MY_IBAN_NUMBER_HERE");
Log.e("isValid: ", b.toString());

calculate , .

+5

iban4j IBAN, , IBAN, , ..

: https://github.com/arturmkrtchyan/iban4j

:

try {
    IbanUtil.validate("AT611904300234573201");
    // valid
} catch (IbanFormatException e) {
    // invalid
}

Maven:

<dependency>
     <groupId>org.iban4j</groupId>
     <artifactId>iban4j</artifactId>
     <version>1.0.0</version>
</dependency>
+2

All Articles