Skip to content

Commit 6429630

Browse files
committed
Deprecate Kjønn og fødselsår fra Fodselsnummer for fjerning
Fra 1.1.2032 vil nye fødselsnummer være kjønnsnøytrale. Vi kommer derfor til å fjerne kjønn fra Fodselsnummer. Fra 1.1.2032 vil nye fødselsnummer tildeles etter ny algoritme. Tildeling av nummere vil starte fra 999 og telle nedover. Individnummerene vil derfor ikke lenger med sikkerhet kunne brukes til å si noe om århundre og derfor ikke alder. Mer info fra Skatteetaten: https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/
1 parent b05bb24 commit 6429630

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

src/main/java/no/bekk/bekkopen/person/Fodselsnummer.java

+36-4
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,30 @@ public String getMonth() {
7373
/**
7474
* Returns the birthyear of the Fodselsnummer
7575
*
76-
* @return A String containing the year of birth.
76+
* @return a String containg the year of birth represented by 2 (two) digits. Century is not included.
77+
*/
78+
public String getYear() {
79+
return get2DigitBirthYear();
80+
}
81+
82+
/**
83+
* Returns the birthyear of the Fodselsnummer
84+
*
85+
* @return A String containing the year of birth represented by 4 (four) digits. Century is included.
86+
* @deprecated For removal - After 1.1.2032 we cannot reliably conclude correct century anymore.
87+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
88+
* replaced by {@link #getYear()}
7789
*/
90+
@Deprecated
7891
public String getBirthYear() {
7992
return getCentury() + get2DigitBirthYear();
8093
}
8194

95+
/**
96+
* @deprecated For removal - After 1.1.2032 we cannot reliably conclude correct century anymore.
97+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
98+
*/
99+
@Deprecated
82100
String getCentury() {
83101
String result = null;
84102
int individnummerInt = Integer.parseInt(getIndividnummer());
@@ -152,9 +170,12 @@ public String getIndividnummer() {
152170

153171
/**
154172
* Returns the digit that decides the gender - the 9th in the Fodselsnummer.
155-
*
173+
*
174+
* @deprecated For removal - Gender will stop working after 1.1.2032
175+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
156176
* @return The digit.
157177
*/
178+
@Deprecated
158179
public int getGenderDigit() {
159180
return getAt(8);
160181
}
@@ -179,18 +200,24 @@ public int getChecksumDigit2() {
179200

180201
/**
181202
* Returns true if the Fodselsnummer represents a man.
182-
*
203+
*
204+
* @deprecated For removal - Gender will stop working after 1.1.2032
205+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
183206
* @return true or false.
184207
*/
208+
@Deprecated
185209
public boolean isMale() {
186210
return getGenderDigit() % 2 != 0;
187211
}
188212

189213
/**
190214
* Returns true if the Fodselsnummer represents a woman.
191-
*
215+
*
216+
* @deprecated For removal - Gender will stop working after 1.1.2032
217+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
192218
* @return true or false.
193219
*/
220+
@Deprecated
194221
public boolean isFemale() {
195222
return !isMale();
196223
}
@@ -264,6 +291,11 @@ private static int getThirdDigit(String fodselsnummer) {
264291
return Integer.parseInt(fodselsnummer.substring(2, 3));
265292
}
266293

294+
/**
295+
* @deprecated For removal - Gender will stop working after 1.1.2032
296+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
297+
*/
298+
@Deprecated
267299
public KJONN getKjonn() {
268300
if (isFemale()) {
269301
return KJONN.KVINNE;

src/main/java/no/bekk/bekkopen/person/FodselsnummerCalculator.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ private FodselsnummerCalculator() {
4747
/**
4848
* Returns a List with valid Fodselsnummer instances for a given Date and gender.
4949
*
50+
* @deprecated For removal - Gender will stop working after 1.1.2032
51+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
52+
*
5053
* @param date en dato
5154
* @param kjonn kjønn
5255
* @return liste med fødselsnummer
5356
*/
54-
57+
@Deprecated
5558
public static List<Fodselsnummer> getFodselsnummerForDateAndGender(Date date, KJONN kjonn) {
5659
List<Fodselsnummer> result = getManyFodselsnummerForDate(date);
5760
splitByGender(kjonn, result);

src/main/java/no/bekk/bekkopen/person/KJONN.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
* #L%
2727
*/
2828

29+
/**
30+
* @deprecated For removal - Gender will stop working after 1.1.2032
31+
* <a href="https://skatteetaten.github.io/folkeregisteret-api-dokumentasjon/nytt-fodselsnummer-fra-2032/">Nytt fødselsnummer fra 2032</a>
32+
*/
33+
@Deprecated
2934
public enum KJONN {
3035

3136
MANN, KVINNE, BEGGE;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package no.bekk.bekkopen.person;
2+
3+
public class KjønnExtractor {
4+
5+
6+
public static KJONN from(Fodselsnummer fodselsnummer) {
7+
return getKjonn(fodselsnummer);
8+
}
9+
10+
public static boolean isFemale(Fodselsnummer fodselsnummer) {
11+
return !isMale(fodselsnummer);
12+
}
13+
14+
public static boolean isMale(Fodselsnummer fodselsnummer) {
15+
return fodselsnummer.getAt(8) % 2 != 0;
16+
}
17+
18+
private static KJONN getKjonn(Fodselsnummer fodselsnummer) {
19+
if (isFemale(fodselsnummer)) {
20+
return KJONN.KVINNE;
21+
} else {
22+
return KJONN.MANN;
23+
}
24+
}
25+
26+
}

0 commit comments

Comments
 (0)