A Java library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).
// How to generate Iban
Iban iban = new Iban.Builder()
.countryCode(CountryCode.AT)
.bankCode("19043")
.accountNumber("00234573201")
.build();
// How to create Iban object from String
Iban iban = Iban.valueOf("DE89370400440532013000");
// How to create Iban object from formatted String
Iban iban = Iban.valueOf("DE89 3704 0044 0532 0130 00", IbanFormat.Default);
// How to generate random Iban
Iban iban = Iban.random(CountryCode.AT);
Iban iban = Iban.random();
Iban iban = new Iban.Builder()
.countryCode(CountryCode.AT)
.bankCode("19043")
.buildRandom();
// How to validate Iban
try {
IbanUtil.validate("AT611904300234573201");
IbanUtil.validate("DE89 3704 0044 0532 0130 00", IbanFormat.Default);
// valid
} catch (IbanFormatException |
InvalidCheckDigitException |
UnsupportedCountryException e) {
// invalid
}
//How to create Bic object from String
Bic bic = Bic.valueOf("DEUTDEFF");
//How to validate Bic
try{
BicUtil.validate("DEUTDEFF500");
// valid
}catch(BicFormatException e){
// invalid
}
//How to left pad('account number', 'bank code' and 'branch code') with zero
Iban iban1=new Iban.Builder()
.leftPadding(true)
.countryCode(CountryCode.DE)
.bankCode("66280099")
.accountNumber("123456700")
.build();
//How to change default padding character ('0') with other
Iban iban2=new Iban.Builder()
.leftPadding(true)
.paddingCharacter('1')
.countryCode(CountryCode.DE)
.bankCode("66280099")
.accountNumber("123456700")
.build();
<dependency>
<groupId>org.iban4j</groupId>
<artifactId>iban4j</artifactId>
<version>3.2.6-RELEASE</version>
</dependency>
- http://en.wikipedia.org/wiki/ISO_13616
- http://en.wikipedia.org/wiki/ISO_9362
- https://www.ecb.europa.eu/paym/retpaym/paymint/sepa/shared/pdf/iban_registry.pdf
Copyright 2015 Artur Mkrtchyan.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0