Date parsing issue After upgrading Elasticsearch JDK

After upgrading the Elastic JDK version in the spring boot application, stopped parsing the date type field to Java Date Objects.

The date field has a default format: strict_date_optional_time||epoch_millis

Java Code:

@Field(type = FieldType.Date, format = DateFormat.date_optional_time)
Date date1;
Sample.1: (Only Date)
date1: "2022-11-21"

When we fetch the data to this document it is giving below parsing error:

Method threw '' exception.
Unable to convert value '2022-11-21' to java.util.Date for property 'date1'
Sample.2: (Date and Time)
date1: "2022-11-21T07:27:28.000Z" 

This is getting parsed successfully. In the index, as we have the date format of optional_date_type it might have date only and date-time both. How can we parse such a date in Java Date Object in the latest version?

The same code was working in an older version.

Elastic Version - 7.17.1
Spring Data Elastic: 7.17.4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.