# How to use offset in DateHistogram.Builder from new java api client

**URL:** <https://discuss.elastic.co/t/how-to-use-offset-in-datehistogram-builder-from-new-java-api-client/314921>\
**Category:** Elasticsearch\
**Created:** [September 22, 2022, 7:25am UTC](https://discuss.elastic.co/t/how-to-use-offset-in-datehistogram-builder-from-new-java-api-client/314921 "2022-09-22T07:25:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raghunandan](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@Raghunandan](https://discuss.elastic.co/u/Raghunandan)\
**Post date:** [September 22, 2022, 7:25am UTC](https://discuss.elastic.co/t/how-to-use-offset-in-datehistogram-builder-from-new-java-api-client/314921/1 "2022-09-22T07:25:35Z")

</div>

in old implementation of DateHistogramAggregationBuilder we could pass offset as string,  
dateHistogramAggregationBuilder.offset(configurationManagementProxy.getStartDayOfWeek() - 1) + "d");

now it requires the offset value in time so how can we do the above change as i checked there is no way to set the Time from co.elastic.clients.elasticsearch.\_types to integer or string value as i am using java api client, for same i checked documentation of datehistogram.builder it only showed usage via curl command and not via java api client.  
IF Possible could you show examples of new java api clients with different types of requests and aggregation as it is difficult to try multiple things manually

---

<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:** [October 20, 2022, 7:25am UTC](https://discuss.elastic.co/t/how-to-use-offset-in-datehistogram-builder-from-new-java-api-client/314921/2 "2022-10-20T07:25:48Z")

</div>

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