# Exception in Date Format while inserting document in Elasticsearch through Java code

**URL:** <https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 12:23pm UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233 "2017-08-24T12:23:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PinkiMondal](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@PinkiMondal](https://discuss.elastic.co/u/PinkiMondal)\
**Post date:** [August 24, 2017, 12:23pm UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233/1 "2017-08-24T12:23:59Z")

</div>

I am getting below error  
MapperParsingException[failed to parse [paymentValueDate]]; nested: IllegalArgumentException[Invalid format: "May 23, 2016"];

And I have used following formats:  
"dd-MM-yy HH:mm:ss.SSSSSSSSS a || dd-MM-yy|| yyyy-MM-dd ||epoch\_millis|| strict\_date\_optional\_time"

Kindly help asap...

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 8:17am UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233/2 "2017-08-25T08:17:16Z")

</div>

which from the date formats you specified do you expect to match against `May 23, 2016`? None of those data formats includes a comma and also not the format for the month in letters so I assume that this is the culprit. You need to add another date format.

---

<div class="post-metadata">

**Author:** ![PinkiMondal](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@PinkiMondal](https://discuss.elastic.co/u/PinkiMondal)\
**Post date:** [August 25, 2017, 9:08am UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233/3 "2017-08-25T09:08:04Z")

</div>

Please correct me if I'm wrong. I couldn't find out any format matching this format in ISO formats.  
Please suggest me one

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 4:08pm UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233/4 "2017-08-25T16:08:23Z")

</div>

you need to construct your own, see the link in the [ES docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#custom-date-formats), that points to the [joda docs](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html) and explains which format you need.

sth like `MMM dd, YYYY` (untested)

---

<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:** [September 22, 2017, 4:08pm UTC](https://discuss.elastic.co/t/exception-in-date-format-while-inserting-document-in-elasticsearch-through-java-code/98233/5 "2017-09-22T16:08:39Z")

</div>

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