# Elasticsearch mapping date format

**URL:** <https://discuss.elastic.co/t/elasticsearch-mapping-date-format/231026>\
**Category:** Elasticsearch\
**Created:** [May 4, 2020, 7:50pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-date-format/231026 "2020-05-04T19:50:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uk300](https://avatars.discourse-cdn.com/v4/letter/u/a8b319/32.png) [@uk300](https://discuss.elastic.co/u/uk300)\
**Post date:** [May 4, 2020, 7:50pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-date-format/231026/1 "2020-05-04T19:50:47Z")

</div>

Hi,

I have a date field and I use painless language to update the date field. Since ES7, I have to pass string rather than LocalDateTime because RestHighLevelClient doesn't take the format specified in the mapping into account, so it adds the zone 'Z' to the date.

LocalDateTime.toString() drops the seconds/ms when the sec/ms is zero e.g. 2019-12-01T12:30:00 or 2019-12-01T12:30:10:000.

Currently this is how the field mapping looks like:

```auto
"updatedDate": {
          "type": "date",
          "format": "strictDateHourMinuteSecondMillis || strictDateHourMinuteSecond || strictDateHourMinute"
}

```

Is it possible to have just a single date format which is strict date and time but sec/ms are optional?

Thank you  
Uthayam

---

<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:** [June 1, 2020, 7:50pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-date-format/231026/2 "2020-06-01T19:50:48Z")

</div>

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