summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/gv/util/ValidationUtils.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/at/gv/util/ValidationUtils.java b/src/main/java/at/gv/util/ValidationUtils.java
index cbc7207..108fe27 100644
--- a/src/main/java/at/gv/util/ValidationUtils.java
+++ b/src/main/java/at/gv/util/ValidationUtils.java
@@ -2,11 +2,16 @@ package at.gv.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.Period;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
import java.util.regex.Pattern;
public class ValidationUtils {
private static final String DATEFORMAT = "dd.MM.yyyy";
+ private static final int REPRESENTATION_MIN_AGE = 14;
public static boolean isDateFormat(String dateString) {
@@ -57,5 +62,19 @@ public class ValidationUtils {
return Pattern.compile("[0-9]{4}").matcher(postcode).matches();
}
+
+ public static boolean isOverThirteen(String representativeDateOfBirth) {
+ try {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATEFORMAT);
+ LocalDate birthdate= LocalDate.parse(representativeDateOfBirth, formatter);
+ Period p = Period.between(birthdate, LocalDate.now());
+ return p.getYears() >= REPRESENTATION_MIN_AGE;
+
+ } catch (DateTimeParseException e) {
+ return false;
+
+ }
+
+ }
}