Class PersonalIdentityNumber
java.lang.Object
se.swedenconnect.bankid.rpapi.support.PersonalIdentityNumber
- All Implemented Interfaces:
Serializable
A representation of a Swedish personal identity number. Also handles "samordningsnummer".
- Author:
- Martin Lindström
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum for formatting a personal identity number. -
Constructor Summary
ConstructorDescriptionPersonalIdentityNumber
(String number) Constructor that parses the supplied personal identity number. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the personal identity number according to thePersonalIdentityNumber.Format.TWELVE_DIGITS_NO_DELIMITER
format.Returns the personal identity number according to the required format.int
hashCode()
boolean
Predicate that returnstrue
if this is a "samordningsnummer".static PersonalIdentityNumber
Parses a personal identity number string into aPersonalIdentityNumber
.toString()
-
Constructor Details
-
PersonalIdentityNumber
Constructor that parses the supplied personal identity number.The following formats are supported:
- 12 digits with no delimiter, e.g. "196904146856".
- 12 digits with a delimiter, e.g. "19690414-6856".
- 10 digits with no delimiter, e.g. "6904146856". In these cases the person is assumed to be under 100 years old.
- 10 digits with a delimiter, e.g. "690414-6856". The year the person is 100 years old, the delimiter changes to '+'.
- Parameters:
number
- the string representation of the personal identity number- Throws:
PersonalIdentityNumberException
- if the supplied number is not valid
-
-
Method Details
-
parse
Parses a personal identity number string into aPersonalIdentityNumber
. SeePersonalIdentityNumber(String)
.- Parameters:
number
- the string representation of the personal identity number- Returns:
- a
PersonalIdentityNumber
object - Throws:
PersonalIdentityNumberException
- if the supplied number is not valid
-
getNumber
Returns the personal identity number according to thePersonalIdentityNumber.Format.TWELVE_DIGITS_NO_DELIMITER
format.- Returns:
- the personal identity number as twelve digits with no delimiter
-
getNumber
Returns the personal identity number according to the required format.- Parameters:
format
- the required format for the personal identity number string- Returns:
- personal identity number string
-
isSamordningsnummer
public boolean isSamordningsnummer()Predicate that returnstrue
if this is a "samordningsnummer".See https://www.skatteverket.se/foretagochorganisationer/myndigheter/informationsutbytemellanmyndigheter/folkbokforingsamordningsnummer.4.46ae6b26141980f1e2d3643.html.
- Returns:
true
if this is a "samordningsnummer" andfalse
otherwise
-
hashCode
public int hashCode() -
equals
-
toString
-