# Date parsing issue After upgrading Elasticsearch JDK

**URL:** <https://discuss.elastic.co/t/date-parsing-issue-after-upgrading-elasticsearch-jdk/320002>\
**Category:** Elasticsearch\
**Created:** [November 29, 2022, 7:15am UTC](https://discuss.elastic.co/t/date-parsing-issue-after-upgrading-elasticsearch-jdk/320002 "2022-11-29T07:15:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![truptir](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@truptir](https://discuss.elastic.co/u/truptir)\
**Post date:** [November 29, 2022, 7:15am UTC](https://discuss.elastic.co/t/date-parsing-issue-after-upgrading-elasticsearch-jdk/320002/1 "2022-11-29T07:15:43Z")

</div>

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:

```auto
@Field(type = FieldType.Date, format = DateFormat.date_optional_time)
Date date1;

```

```auto
Sample.1: (Only Date)
date1: "2022-11-21"

```

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

```auto
Method threw 'org.springframework.data.elasticsearch.core.convert.ConversionException' exception.
Unable to convert value '2022-11-21' to java.util.Date for property 'date1'

```

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 27, 2022, 7:16am UTC](https://discuss.elastic.co/t/date-parsing-issue-after-upgrading-elasticsearch-jdk/320002/2 "2022-12-27T07:16:20Z")

</div>

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