Class Iban

  • All Implemented Interfaces:
    Serializable

    public final class Iban
    extends Object
    implements Serializable
    An International Bank Account Number (IBAN) Code as specified by the ISO 13616:2007 standard.

    An IBAN consists of a two-letter ISO 3166-1 country code, followed by two check digits and up to thirty alphanumeric characters for a BBAN (Basic Bank Account Number) which has a fixed length per country and, included within it, a bank identifier with a fixed position and a fixed length per country. The check digits are calculated based on the scheme defined in ISO/IEC 7064 (MOD97-10). Note that an IBAN is case-insensitive.

    This class handles validation of the check digit and validation of the BBAN structure.

    Instances of this class are immutable and are safe for use by multiple concurrent threads.

    Since:
    1.0
    Author:
    Marc Wrobel
    See Also:
    BbanStructure, http://wikipedia.org/wiki/International_Bank_Account_Number, https://www.iso13616.org, Serialized Form
    • Constructor Detail

      • Iban

        public Iban​(IsoCountry country,
                    String bban)
        Create a new IBAN from the given country code and BBAN.
        Parameters:
        country - A non-null IsoCountry.
        bban - A non-null String.
        Throws:
        IllegalArgumentException - if either the IsoCountry or BBAN is null
        IbanFormatException - if a valid IBAN could not be calculated using the given IsoCountry and BBAN.
    • Method Detail

      • isValid

        public static boolean isValid​(String iban)
        Validates the given IBAN String.
        Parameters:
        iban - A String.
        Returns:
        true if the given String is a valid IBAN, false otherwise.
      • getCountryCode

        public String getCountryCode()
        Extract the ISO 3166-1-alpha-2 country code from this IBAN.
        Returns:
        A non-null string representing this IBAN ISO 3166-1-alpha-2 country code.
      • getCheckDigit

        public String getCheckDigit()
        Extract the check digit from this IBAN.
        Returns:
        A non-null string representing this IBAN check digit.
      • getBban

        public String getBban()
        Extract the BBAN from this IBAN.
        Returns:
        A non-null string representing this IBAN BBAN.
      • toPrintableString

        public String toPrintableString()
        Gets the printable version of this IBAN.

        When printed on paper, the IBAN is expressed in groups of four characters separated by a single space, the last group being of variable length

        Returns:
        A non-null string representing this IBAN formatted for printing.
      • hashCode

        public int hashCode()
        Returns a normalized string representation of this IBAN.

        Normalized means the string is:

        • made of uppercase characters
        • contains no spaces
        Overrides:
        hashCode in class Object
        Returns:
        a normalized string representation of this IBAN