List of utility methods to do DateTimeFormatter
ZonedDateTime | parseZoneDateTime(String value, DateTimeFormatter formatter) Workaround for https://bugs.openjdk.java.net/browse/JDK-8066982, which at the moment has only been solved for JDK9. TemporalAccessor temporal = formatter.parse(value); if (!temporal.isSupported(ChronoField.OFFSET_SECONDS)) { return ZonedDateTime.from(temporal); ZoneId zone = ZoneId.from(temporal); ZoneOffset offset = ZoneOffset.from(temporal); LocalDateTime ldt = LocalDateTime.from(temporal); return ZonedDateTime.ofInstant(ldt, offset, zone); ... |
void | setDateFormat(String pattern) set Date Format dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
dateFormat = new SimpleDateFormat(pattern);
|
LocalDate | validateDate(String input, DateTimeFormatter formatter) validate Date if (!input.isEmpty()) { try { LocalDate date = LocalDate.parse(input, formatter); if (validateDate(date)) { return date; } catch (Exception e) { return null; ... |