public final class IBANCheckDigit extends Object implements CheckDigit, Serializable
This rountine is based on the ISO 7064 Mod 97,10 check digit caluclation routine.
The two check digit characters in a IBAN number are the third and fourth characters
in the code. For check digit calculation/validation the first four characters are moved
to the end of the code.
So CCDDnnnnnnn
becomes nnnnnnnCCDD
(where
CC
is the country code and DD
is the check digit). For
check digit calcualtion the check digit value should be set to zero (i.e.
CC00nnnnnnn
in this example.
For further information see Wikipedia - IBAN number.
Modifier and Type | Field and Description |
---|---|
static CheckDigit |
IBAN_CHECK_DIGIT
Singleton IBAN Number Check Digit instance
|
Constructor and Description |
---|
IBANCheckDigit()
Construct Check Digit routine for IBAN Numbers.
|
Modifier and Type | Method and Description |
---|---|
String |
calculate(String code)
Calculate the Check Digit for an IBAN code.
|
boolean |
isValid(String code)
Validate the check digit for an the IBAN code.
|
public static final CheckDigit IBAN_CHECK_DIGIT
public IBANCheckDigit()
public boolean isValid(String code)
isValid
in interface CheckDigit
code
- The code to validatetrue
if the check digit is valid, otherwise
false
public String calculate(String code) throws CheckDigitException
Note: The check digit is the third and fourth
characters and and should contain value "00
".
calculate
in interface CheckDigit
code
- The code to calculate the Check Digit forCheckDigitException
- if an error occurs calculating
the check digit for the specified codeCopyright © 2002–2014 The Apache Software Foundation. All rights reserved.