Package nl.garvelink.iban
package nl.garvelink.iban
This package provides a value type for IBAN numbers. Its main entity is
IBAN, an
immutable value type representing an IBAN number. The Modulo-97 checksum is implemented in
Modulo97, which can be used directly if needed. The code in this package
throws IllegalArgumentException on invalid input. Methods don't take null arguments unless otherwise
noted.
Usage sample
// Obtain an instance of IBAN. IBAN iban = IBAN.valueOf( "NL91ABNA0417164300" ); // toString() emits standard formatting, toPlainString() is compact. String s = iban.toString(); // "NL91 ABNA 0417 1643 00" String p = iban.toPlainString(); // "NL91ABNA0417164300" // Input may be formatted. iban = IBAN.valueOf( "BE68 5390 0754 7034" ); // The valueOf() method returns null if its argument is null. iban.valueOf( null ); // null // The parse() method throws an exception if its argument is null. iban.parse( null ); // IllegalArgumentException // IBAN does not implement Comparable<T>, but a simple Comparator is provided. List<IBAN> ibans = getListOfIBANs(); Collections.sort( ibans, IBAN.LEXICAL_ORDER ); // The equals() and hashCode() methods are implemented. Map<IBAN, String> ibansAsKeys = Maps.newHashMap(); ibansAsKeys.put( iban, "this is fine" ); // You can use the Modulo97 class directly to compute or verify the check digits on an input. String candidate = "GB29 NWBK 6016 1331 9268 19"; boolean valid = Modulo97.verifyCheckDigits( candidate ); // true // Modulo97 API methods take CharSequence, not just String. StringBuilder builder = new StringBuilder( "LU000019400644750000" ); int checkDigits = Modulo97.calculateCheckDigits( builder ); // 28 // Get the expected IBAN length for a country code: int length = CountryCodes.getLengthForCountryCode( "DK" );
Copyright 2021 Barend Garvelink. This code can be used under the terms of the Apache License, Version 2.0. Attribution is appreciated, but not required.
-
ClassDescriptionContains information about IBAN country codes.An immutable value type representing an International Bank Account Number.Base class for all exceptions thrown by this library.Extracts national encoded information from IBANs.Extracts national encoded information from IBANs.Indicates that some given input could not be successfully parsed into an IBAN.Calculates the modulo 97 checksum used in IBAN numbers (and some other entities).Indicates that an IBAN failed validation because its embedded country code is unknown.Indicates that a candate IBAN failed validation because its stated check digits didn't match the calculated expectation.Indicates that a candate IBAN failed validation because it's the wrong length for its country code.