# Issue with date format change while reindexing

**URL:** <https://discuss.elastic.co/t/issue-with-date-format-change-while-reindexing/169590>\
**Category:** Elasticsearch\
**Created:** [February 22, 2019, 2:00pm UTC](https://discuss.elastic.co/t/issue-with-date-format-change-while-reindexing/169590 "2019-02-22T14:00:50Z")\
**Posts on this page:** 1\
**Showing post:** 11

<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:** [February 26, 2019, 5:33pm UTC](https://discuss.elastic.co/t/issue-with-date-format-change-while-reindexing/169590/11 "2019-02-26T17:33:54Z")

</div>

Here is a way to do it:

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline" :{
  "description": "date pipeline ",
  "processors": [
    {
        "script": {
          "source": """
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
             ctx.person.birthDate = format.format(format.parse(ctx.person.birthDate));
          """
        }
    }
  ]},
  "docs": [
    {
      "_index": "index",
      "_type": "_doc",
      "_id": "id",
       "_source": {
          "person": {
            "birthDate": "1950-01-01T12:00:00.000Z"
          }
       }
    }
  ]
}

```

This gives:

```auto
{
  "docs" : [
    {
      "doc" : {
        "_index" : "index",
        "_type" : "_doc",
        "_id" : "id",
        "_source" : {
          "person" : {
            "birthDate" : "1950-01-01"
          }
        },
        "_ingest" : {
          "timestamp" : "2019-02-26T17:35:45.52603Z"
        }
      }
    }
  ]
}

```

HTH

---

_[View the full topic](https://discuss.elastic.co/t/issue-with-date-format-change-while-reindexing/169590)._
