# Invalid Date Format

**URL:** https://discuss.elastic.co/t/invalid-date-format/221076
**Category:** Elasticsearch
**Created:** [February 26, 2020, 4:25pm UTC](https://discuss.elastic.co/t/invalid-date-format/221076 "2020-02-26T16:25:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alinaalam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alinaalam/32/45475_2.png) [@alinaalam](https://discuss.elastic.co/u/alinaalam)
#### Post date: [February 26, 2020, 4:25pm UTC](https://discuss.elastic.co/t/invalid-date-format/221076/1 "2020-02-26T16:25:23Z")

</div>

This is my index mapping:

```
 "properties": {
                "hour": {
                    "type": "date"
                },
                "timestamp": {
                    "type": "date"
                }
            }

```

I am trying to add different entries having different timestamps. I am using Java and storing LocalDateTime from my app. It works fine for a lot of entries, but for some entries, it fails with the error:

```
ERROR ElasticsearchException[Elasticsearch exception [type=exception, reason=java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: unable to parse date [2020-02-18T13:42:54Z]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=java.lang.IllegalArgumentException: unable to parse date [2020-02-18T13:42:54Z]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unable to parse date [2020-02-18T13:42:54Z]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Invalid format: "2020-02-18T13:42:54Z" is malformed at "Z"]];

```

I understand that ES also wants milliseconds, but in this case, the time doesn't have millis so they can automatically be truncated, but the object is still a valid LocalDateTime object so ES should accept it. I thought the problem could be in the fact that ES is pretty strict and won't accept anything unless I append 000 with the date. However, the funny thing is that when I manually run a query on ES, it accepted the entry without any problem

```
{
"took": 296,
"timed_out": false,
"_shards": {
    "total": 400,
    "successful": 400,
    "skipped": 0,
    "failed": 0
},
"hits": {
    "total": 1,
    "max_score": null,
    "hits": [
        {
            "_source": {
                "hour": "2020-02-19T15:00Z",
                "timestamp": "2020-02-18T13:42:54Z"
            }
        }
    ]
 }
}

```

What exactly am I missing here?

---

<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: [March 25, 2020, 4:26pm UTC](https://discuss.elastic.co/t/invalid-date-format/221076/2 "2020-03-25T16:26:33Z")

</div>

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