# Wrong Timezone in Painless Function

**URL:** <https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 28, 2019, 7:49pm UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905 "2019-11-28T19:49:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [November 28, 2019, 7:49pm UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/1 "2019-11-28T19:49:27Z")

</div>

The government of our country recently canceled daylight saving time, and now functions using timezone return to America / Sao\_Paulo the value -02 instead of -03, but if I test with America / Buenos\_Aires, the value returned is the correct one , -03.

I am using this code to group documents by time:

```
"aggs":{
    "group":{
        "terms":{
            "script":{
                "inline":"Instant.ofEpochMilli(doc.datahora.date.millis).atZone(ZoneId.of(params.tz)).hour",
                "lang":"painless",
                "params":{
                    "tz":"America\/Sao_Paulo"
                }
            }
        }
    }
}

```

Is there anything I should update on my server?  
The operating system is up to date, as are all packages.

---

<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:** [November 29, 2019, 8:09am UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/2 "2019-11-29T08:09:21Z")

</div>

Three question to help here:

1. Can you tell us, when that change of cancelling DST happened?
2. Which Elasticsearch version are you using?
3. Which version of the JDK are you using?

The reason for this question is, that this kind of information is usually stored in something called a timezone database, which might not be up-to-date in older versions.

Thanks!

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [November 29, 2019, 12:47pm UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/3 "2019-11-29T12:47:43Z")

</div>

1. Daylight Saving Time change occurred on 2019/07/01
2. ElasticSearch Version: 6.8.4
3. Java: 1.8.0\_201 (even with apt upgrade it does not update to the latest available version)

---

<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:** [December 2, 2019, 9:27am UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/4 "2019-12-02T09:27:13Z")

</div>

so, the 6.8 dominantly uses joda time. Looking at [https://github.com/elastic/elasticsearch/blob/v6.8.4/buildSrc/version.properties#L22](https://github.com/elastic/elasticsearch/blob/v6.8.4/buildSrc/version.properties#L22) it seems that 6.8.4 was shipped with joda time 2.10.1 that was created in october 2018. However the timezone database was only updated in 2019 with the brazil change.

Would it be possible for you to test with a latest 7.4 release, as that one mainly uses java time.

I will check if it makes sense to update the 6.x branch with the latest joda release to include such changes.

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [December 2, 2019, 2:33pm UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/5 "2019-12-02T14:33:55Z")

</div>

I believe I fixed the server problem using the [Timezone Updater Tool.](https://www.oracle.com/technetwork/java/javase/documentation/tzupdater-readme-136440.html)

---

<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 30, 2019, 2:33pm UTC](https://discuss.elastic.co/t/wrong-timezone-in-painless-function/209905/6 "2019-12-30T14:33:55Z")

</div>

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