# Things to change in elastic java high level client code for moving from joda to java time

**URL:** <https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872>\
**Category:** Elasticsearch\
**Created:** [December 14, 2019, 12:46pm UTC](https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872 "2019-12-14T12:46:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)\
**Post date:** [December 14, 2019, 12:46pm UTC](https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872/1 "2019-12-14T12:46:33Z")

</div>

what are the things to change in elastic java high-level client code for moving from joda to java time ?

my current code is as below. I am using 6.8.3 elk version

I need to change code, so I can use it in elk 7.4

```
     TimeZone timezoneID = TimeZone.getTimeZone("America/chicago");

     SearchResponse response = hclient.search(new SearchRequest("metricbeat*")
                    .source(

                            new SearchSourceBuilder()

                                    .aggregation(
                                            AggregationBuilders.dateHistogram("mainAgg")
                                                    .field("@timestamp")    
                                                    .dateHistogramInterval("1d")     
                                                    .format("dd/MM/YYYY")  
                                                    .timeZone(DateTimeZone.forTimeZone(timezoneID))
                                                    .minDocCount(0)
                                                    .order(BucketOrder.key(false))

                                    )
                                    .size(0)
                    ), RequestOptions.DEFAULT);
```

---

<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 16, 2019, 8:54am UTC](https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872/2 "2019-12-16T08:54:28Z")

</div>

Hey,

you need to replace the timeZone with a java based timezone, i.e. by calling `ZoneId.of` or `ZoneOffset.of` - the good thing with java will be that this will be a compilation error, so you can spot it early.

--Alex

---

<div class="post-metadata">

**Author:** ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)\
**Post date:** [December 21, 2019, 3:22pm UTC](https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872/3 "2019-12-21T15:22:15Z")

</div>

Thanks sir

---

<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:** [January 18, 2020, 3:22pm UTC](https://discuss.elastic.co/t/things-to-change-in-elastic-java-high-level-client-code-for-moving-from-joda-to-java-time/211872/4 "2020-01-18T15:22:16Z")

</div>

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