# Date Mapping Parse Failure

**URL:** <https://discuss.elastic.co/t/date-mapping-parse-failure/256469>\
**Category:** Elasticsearch\
**Created:** [November 24, 2020, 8:52am UTC](https://discuss.elastic.co/t/date-mapping-parse-failure/256469 "2020-11-24T08:52:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nara1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@nara1](https://discuss.elastic.co/u/nara1)\
**Post date:** [November 24, 2020, 8:52am UTC](https://discuss.elastic.co/t/date-mapping-parse-failure/256469/1 "2020-11-24T08:52:52Z")

</div>

Hello there,

I am trying to send a date in the format `2020-10-29T05:36:06.143Z[UTC]`. My mapping looks like this:

```auto
    "timeStamp": {
      "type": "date"
    }

```

And I am getting the following error:

```auto
Elasticsearch exception [type=mapper_parsing_exception, reason=failed to parse field [createdTimeStamp] of type [date] in document with id 'testId'.

Preview of field's value: 
'{offset={totalSeconds=0, rules={fixedOffset=true, transitionRules=[], transitions=[]}, id=Z}, year=2020, dayOfYear=303, nano=143000000, chronology={calendarType=iso8601, id=ISO}, minute=36, second=6, dayOfWeek=THURSDAY, month=OCTOBER, hour=5, zone={rules={fixedOffset=true, transitionRules=[], transitions=[]}, id=UTC}, dayOfMonth=29, monthValue=10}']]; 

nested: ElasticsearchException[Elasticsearch exception [type=illegal_state_exception, reason=Can't get text on a START_OBJECT at 1:72]];

```

I have tried:  
`format: "date_optional_time"` - get above error  
`format: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'[UTC]"` - get `type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]: Invalid format: [yyyy-MM-dd'T'HH:mm:ss.SSS'Z'[UTC]]: Unknown pattern letter: U]`

Any other tips on how I can get this mapping to work? It's curious because I have another application that sends dates in the exact same format, transforms it to a ZonedDateTime (like I am doing), and only uses "type: date", and it works. I'm not sure what to try next, any advice is appreciated!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 24, 2020, 9:24am UTC](https://discuss.elastic.co/t/date-mapping-parse-failure/256469/2 "2020-11-24T09:24:51Z")

</div>

Welcome.

Try may be `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` instead?  
Have a look at

> **[format | Elasticsearch Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)**

It gives lot of examples and also predefined formats.

If you still can't make it work, please provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![nara1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@nara1](https://discuss.elastic.co/u/nara1)\
**Post date:** [November 25, 2020, 11:29pm UTC](https://discuss.elastic.co/t/date-mapping-parse-failure/256469/3 "2020-11-25T23:29:50Z")

</div>

Thanks! The problem ended up being that when my ObjectMapper was stringifying my object, the date was getting parsed into a nested object.

I ended up initializing my ObjectMapper like so:

```auto
    public ObjectMapper getObjectMapper() {
        return new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
                .registerModule(new JavaTimeModule());
    }

```

Thanks for the help!

---

<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 23, 2020, 11:29pm UTC](https://discuss.elastic.co/t/date-mapping-parse-failure/256469/4 "2020-12-23T23:29:54Z")

</div>

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