Java Utililty Methods DateTimeFormatter

List of utility methods to do DateTimeFormatter

Description

The list of methods to do DateTimeFormatter are organized into topic(s).

Method

ZonedDateTimeparseZoneDateTime(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);
...
voidsetDateFormat(String pattern)
set Date Format
dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
dateFormat = new SimpleDateFormat(pattern);
LocalDatevalidateDate(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;
...