diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateFormat.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateFormat.java index c4b96bb06b0b2..7da69ed1b2bea 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateFormat.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateFormat.java @@ -100,7 +100,7 @@ Function getFunction(String format, ZoneId zoneId, Locale TemporalAccessor accessor = formatter.parse(text); // if there is no year nor year-of-era, we fall back to the current one and // fill the rest of the date up with the parsed date - if (accessor.isSupported(ChronoField.YEAR) == false && accessor.isSupported(ChronoField.YEAR_OF_ERA) == false ) { + if (accessor.isSupported(ChronoField.YEAR) == false /*&& accessor.isSupported(ChronoField.YEAR_OF_ERA) == false */) { int year = LocalDate.now(ZoneOffset.UTC).getYear(); ZonedDateTime newTime = Instant.EPOCH.atZone(ZoneOffset.UTC).withYear(year); for (ChronoField field : FIELDS) { diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 0bdf318ce78b4..eab748c6acee4 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -1841,7 +1841,7 @@ public static ZonedDateTime from(TemporalAccessor accessor) { zoneId = ZoneOffset.UTC; } - LocalDate localDate = accessor.query(LOCAL_DATE_QUERY); + LocalDate localDate = accessor.query(TemporalQueries.localDate());//accessor.query(LOCAL_DATE_QUERY); LocalTime localTime = accessor.query(TemporalQueries.localTime()); boolean isLocalDateSet = localDate != null; boolean isLocalTimeSet = localTime != null; @@ -1859,8 +1859,10 @@ public static ZonedDateTime from(TemporalAccessor accessor) { if (accessor.isSupported(MONTH_OF_YEAR)) { return getFirstOfMonth(accessor).atStartOfDay(zoneId); } else { - int year = getYear(accessor); - return Year.of(year).atDay(1).atStartOfDay(zoneId); + return Year.of(accessor.get(ChronoField.YEAR)).atDay(1).atStartOfDay(zoneId); + +// int year = getYear(accessor); +// return Year.of(year).atDay(1).atStartOfDay(zoneId); } } else if (accessor.isSupported(MONTH_OF_YEAR)) { // missing year, falling back to the epoch and then filling @@ -1941,6 +1943,8 @@ private static ZonedDateTime of(LocalDate localDate, LocalTime localTime, ZoneId @SuppressForbidden(reason = "LocalDate.of is fine here") private static LocalDate getFirstOfMonth(TemporalAccessor accessor) { - return LocalDate.of(getYear(accessor), accessor.get(MONTH_OF_YEAR), 1); +// return LocalDate.of(getYear(accessor), accessor.get(MONTH_OF_YEAR), 1); + return LocalDate.of(accessor.get(ChronoField.YEAR), accessor.get(MONTH_OF_YEAR), 1); + } }