We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4015e7b commit 788d06aCopy full SHA for 788d06a
code-samples-base/src/main/java/org/fugerit/java/code/samples/base/AgeCheck.java
@@ -1,14 +1,15 @@
1
package org.fugerit.java.code.samples.base;
2
3
import java.time.LocalDate;
4
+import java.time.Period;
5
import java.time.temporal.ChronoUnit;
6
7
public class AgeCheck {
8
9
private AgeCheck() {}
10
11
public static Boolean isAgeAtLeast(LocalDate d, int numberOfYears) {
- return d != null && d.until(LocalDate.now(), ChronoUnit.YEARS)>=numberOfYears;
12
+ return d != null && Period.between(d, LocalDate.now()).getYears() >=numberOfYears;
13
}
14
15
public static Boolean isAgeAtLeast18(LocalDate d) {
0 commit comments