# Elastic joda to java time update - Illegal pattern component: uuuu

**URL:** <https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830>\
**Category:** Elasticsearch\
**Created:** [June 19, 2020, 3:43pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830 "2020-06-19T15:43:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![krrz](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@krrz](https://discuss.elastic.co/u/krrz)\
**Post date:** [June 19, 2020, 3:43pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/1 "2020-06-19T15:43:06Z")

</div>

I'm trying update joda time to java time in pipeline.  
And after copy sample from  
[java-time-migration-update-ingest-pipelines](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/migrate-to-java-time.html#java-time-migration-update-ingest-pipelines)  
I get "Illegal pattern component: uuuu" error.  
Some examples

# working, but changed index\_name\_format

also upgrade assistant - my\_pipeline, fields: [[field: index\_name\_format, format: yyyy-w, suggestion: 'y' year should be replaced with 'u'. Use 'y' for year-of-era.]]

## reqests

```
PUT /_ingest/pipeline/my_pipeline?pretty
{
  "description": "Pipeline for routing data to specific index",
  "processors": [
    {
      "date": {
        "field": "createdTime",
        "formats": [
         "8uuuu-w"
        ]
      },
      "date_index_name": {
        "field": "@timestamp",
        "date_rounding": "d",
        "index_name_prefix": "x-",
        "index_name_format": "yyyy-w"
      }
    }
  ]
}
POST /notexistingindice/doc?pipeline=my_pipeline
{
  "createdTime": "2020-15"
}
GET x-*

```

## response

```
# PUT /_ingest/pipeline/my_pipeline?pretty
#! Deprecation: 'y' year should be replaced with 'u'. Use 'y' for year-of-era.; 'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. Prefix your date format with '8' to use the new specifier.
{
  "acknowledged" : true
}

# POST /notexistingindice/doc?pipeline=my_pipeline
#! Deprecation: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
#! Deprecation: 'y' year should be replaced with 'u'. Use 'y' for year-of-era. Prefix your date format with '8' to use the new specifier.
{
  "_index" : "x-2020-1",
  "_type" : "doc",
  "_id" : "ZCg4zXIB127-7IpTKDKa",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

# GET x-*
#! Deprecation: [types removal] The parameter include_type_name should be explicitly specified in get indices requests to prepare for 7.0. In 7.0 include_type_name will default to 'false', which means responses will omit the type name in mapping definitions.
{
  "x-2020-1" : {
    "aliases" : { },
    "mappings" : {
      "doc" : {
        "properties" : {
          "@timestamp" : {
            "type" : "date"
          },
          "createdTime" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1592580909116",
        "number_of_shards" : "5",
        "number_of_replicas" : "1",
        "uuid" : "IWwAFih-QAWoatz8RnBKBw",
        "version" : {
          "created" : "6081099"
        },
        "provided_name" : "<x-{2020-1||/d{yyyy-w|UTC}}>"
      }
    }
  }
}

```

# not working, copied from page

## reqests

```
PUT /_ingest/pipeline/my_pipeline?pretty
{
  "description": "Pipeline for routing data to specific index",
  "processors": [
    {
      "date": {
        "field": "createdTime",
        "formats": [
         "8uuuu-w"
        ]
      },
      "date_index_name": {
        "field": "@timestamp",
        "date_rounding": "d",
        "index_name_prefix": "x-",
        "index_name_format": "8uuuu-w"
      }
    }
  ]
}
POST /notexistingindice/doc?pipeline=my_pipeline
{
  "createdTime": "2020-20"
}
GET x-*

```

## response

```
# PUT /_ingest/pipeline/my_pipeline?pretty
#! Deprecation: 'y' year should be replaced with 'u'. Use 'y' for year-of-era.; 'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. Prefix your date format with '8' to use the new specifier.
{
  "acknowledged" : true
}

# POST /notexistingindice/doc?pipeline=my_pipeline
{
  "error": {
"root_cause": [
  {
    "type": "illegal_argument_exception",
    "reason": "Illegal pattern component: uuuu"
  }
],
"type": "illegal_argument_exception",
"reason": "Illegal pattern component: uuuu"
  },
  "status": 400
}

```

# but simulate is working

## reqests

```
POST _ingest/pipeline/my_pipeline/_simulate
{
  "docs": [
    {
      "_source": {
        "createdTime": "2020-20"
      }
    }
  ]
}

```

## response

```
{
  "docs" : [
    {
      "doc" : {
        "_index" : "<x-{2020-1||/d{8uuuu-w|UTC}}>",
        "_type" : "_type",
        "_id" : "_id",
        "_source" : {
          "createdTime" : "2020-20",
          "@timestamp" : "2020-01-01T00:00:00.000Z"
        },
        "_ingest" : {
          "timestamp" : "2020-06-19T15:41:57.053Z"
        }
      }
    }
  ]
}
```

---

<div class="post-metadata">

**Author:** ![krrz](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@krrz](https://discuss.elastic.co/u/krrz)\
**Post date:** [June 23, 2020, 7:17am UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/2 "2020-06-23T07:17:57Z")

</div>

Any suggestions?

---

<div class="post-metadata">

**Author:** ![pgomulka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pgomulka/32/45766_2.png) [@pgomulka](https://discuss.elastic.co/u/pgomulka)\
**Post date:** [June 23, 2020, 4:37pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/3 "2020-06-23T16:37:49Z")

</div>

@krrz can you confirm what version are you using?

---

<div class="post-metadata">

**Author:** ![krrz](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@krrz](https://discuss.elastic.co/u/krrz)\
**Post date:** [June 23, 2020, 7:28pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/4 "2020-06-23T19:28:56Z")

</div>

I use 6.8.

---

<div class="post-metadata">

**Author:** ![pgomulka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pgomulka/32/45766_2.png) [@pgomulka](https://discuss.elastic.co/u/pgomulka)\
**Post date:** [June 24, 2020, 11:25am UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/5 "2020-06-24T11:25:34Z")

</div>

thank you for raising this. This indeed highlights multiple problems.  
Please bear in mind that you are using incorrect date formats for week based years. Joda is fairly flexible when it comes to this, but it is an undocumented implementation details that `yyyy-w` would allow parsing week based year. You should be using `xxxx-w` for joda and `YYYY-w` for java.time.  
See [https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html](https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html)  
and [https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)

Apart from this I noticed these problems on ES side.  
Firstly - date processor is not correctly parsing week based dates. I raised this [https://github.com/elastic/elasticsearch/issues/58479](https://github.com/elastic/elasticsearch/issues/58479)

Secondly - There is also a problem with bwc layer for `date index name` processor. I gathered all the details here [https://github.com/elastic/elasticsearch/issues/58481](https://github.com/elastic/elasticsearch/issues/58481)

Lastly - There is a problem simply parsing dates in week based dates (no ingest processor used) affecting versions 6.8 - 7.5 [https://github.com/elastic/elasticsearch/issues/42588#issuecomment-648708791](https://github.com/elastic/elasticsearch/issues/42588#issuecomment-648708791)

Please do follow these 3 issuses and I will provide more updates there.

Thank you

---

<div class="post-metadata">

**Author:** ![krrz](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@krrz](https://discuss.elastic.co/u/krrz)\
**Post date:** [June 24, 2020, 12:36pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/6 "2020-06-24T12:36:02Z")

</div>

Thank you for response.

From my point of view the most interesting is [https://github.com/elastic/elasticsearch/issues/58481](https://github.com/elastic/elasticsearch/issues/58481).

---

<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:** [July 22, 2020, 12:40pm UTC](https://discuss.elastic.co/t/elastic-joda-to-java-time-update-illegal-pattern-component-uuuu/237830/7 "2020-07-22T12:40:17Z")

</div>

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