1
0
This commit is contained in:
2023-02-21 18:31:01 +01:00
parent 455cb63652
commit b6e6a94a1e
20 changed files with 495 additions and 21 deletions

View File

@@ -0,0 +1,16 @@
package de.nbscloud.webcontainer.shared.util;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
public class ControllerUtils {
public static LocalDate parseDate(String date) {
// The format is always "yyyy-MM-dd", see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
return Optional.ofNullable(date)
.map(ed -> ed.isBlank() ? null : ed)
.map(ed -> LocalDate.parse(ed, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.orElse(null);
}
}