A port of Artur Mkrtchyan's iban4j project, so that it works in a pure Java project and projects using GWT or J2CL. Artur's project can be found here
A Java, GWT and J2CL ready library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362). The library can be used on the client and server side!
The library can be used in a Java-, GWT- or J2CL-environment.
Documentation and most of the classes are copied from iban4j.
That's the way how to generate an Iban using the new keyword:
Iban iban = new Iban.Builder()
.countryCode(CountryCode.AT)
.bankCode("19043")
.accountNumber("00234573201")
.build();
and that is the way to generate an IBAN without using the new keyword:
Iban iban = Iban.builder()
.countryCode(CountryCode.AT)
.bankCode("19043")
.accountNumber("00234573201")
.build();
Creating an Iban object from String:
Iban iban = Iban.valueOf("DE89370400440532013000");
and from formatted String:
Iban iban = Iban.valueOf("DE89 3704 0044 0532 0130 00", IbanFormat.Default);
Generating a random Iban:
// How to generate random Iban
Iban iban = Iban.random(CountryCode.AT);
Iban iban = Iban.random();
Iban iban = Iban.builder()
.countryCode(CountryCode.AT)
.bankCode("19043")
.buildRandom();
Validating an 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
}
<dependency>
<groupId>com.github.nalukit</groupId>
<artifactId>iban4g</artifactId>
<version>2.2.0</version>
</dependency>
(Only in case you are using iban4g with GWT!)
<inherits name="com.github.nalukit.iban4g.Iban4g" />
- Artur Mkrtchyan's IBAN4j project
- https://en.wikipedia.org/wiki/ISO_13616
- https://en.wikipedia.org/wiki/ISO_9362
- https://www.ecb.europa.eu/paym/retpaym/paymint/sepa/shared/pdf/iban_registry.pdf
- https://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
- https://www.swift.com/resource/iban-registry-pdf
- https://bank.codes/iban/structure
Please use the Nalu Gitter room.
In case you find a bug, please open an issue.
Copyright 2015 Artur Mkrtchyan
Modifications Copyright 2020 Frank Hossfeld
Licensed under the Apache License, Version 2.0: https://www.apache.org/licenses/LICENSE-2.0