Class Iban
- java.lang.Object
-
- fr.marcwrobel.jbanking.iban.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 Summary
Constructors Constructor Description Iban(IsoCountry country, String bban)Create a new IBAN from the given country code and BBAN.Iban(String iban)Create a new IBAN from the given string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetBban()Extract the BBAN from this IBAN.StringgetCheckDigit()Extract the check digit from this IBAN.StringgetCountryCode()Extract the ISO 3166-1-alpha-2 country code from this IBAN.inthashCode()Returns a normalized string representation of this IBAN.static booleanisValid(String iban)Validates the given IBAN String.StringtoPrintableString()Gets the printable version of this IBAN.StringtoString()
-
-
-
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 nullIbanFormatException- if a valid IBAN could not be calculated using the given IsoCountry and BBAN.
-
Iban
public Iban(String iban)
Create a new IBAN from the given string.- Parameters:
iban- A non-null String.- Throws:
IllegalArgumentException- if the given string is nullIbanFormatException- if the given string is not a valid IBAN.
-
-
Method Detail
-
isValid
public static boolean isValid(String iban)
Validates the given IBAN String.- Parameters:
iban- A String.- Returns:
trueif the given String is a valid IBAN,falseotherwise.
-
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.
-
-