Reputation: 15
Problem statement I have a Swedish Bank (SEB) account number and I need to generate the IBAN for this account number (in java code)
A possibility I can see that it's possible if I use website: https://www.ibancalculator.com/
What I tried https://github.com/arturmkrtchyan/iban4j
Iban iban = new Iban.Builder()
.countryCode(CountryCode.SE)
.bankCode("XXXX")
.accountNumber("XXXXXXX")
.build();
Here X is a digit in my account number and the account number is overall 11 digits long (first 4 are clearing number and next 7 is account number).
However, when I try this, I get the following: length is 11, expected BBAN length is: 20
Can someone please point out what am I doing wrong here OR is there some other better way.
P.S. If I use same values on the ibancalculator.com, I get the correct IBAN for my account.
Upvotes: 1
Views: 2325
Reputation: 474
The digits you putted in the bank code and in the account number are totally 11, but the iban requires 20 digits.
As you can see in the GitHub reference, you must put all the digits, so add the four digits you mentioned ("first 4 are clearing number") in the accountNumber and add the necessary digits in the bank code.
Upvotes: 0
Reputation: 12194
The error you obtain gives a hint that you need to use full length of the account number as indicated in this example:
Iban iban = new Iban.Builder()
.countryCode(CountryCode.SE)
.bankCode("500")
.accountNumber("0000005839825746")
.build();
In other words, ensure that you are supplying expected 20 digits before calling .build()
.
Upvotes: 2