# How to set TimeStamp from java?

**URL:** <https://discuss.elastic.co/t/how-to-set-timestamp-from-java/308812>\
**Category:** Elasticsearch\
**Created:** [July 4, 2022, 11:55am UTC](https://discuss.elastic.co/t/how-to-set-timestamp-from-java/308812 "2022-07-04T11:55:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enomine](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@Enomine](https://discuss.elastic.co/u/Enomine)\
**Post date:** [July 4, 2022, 11:55am UTC](https://discuss.elastic.co/t/how-to-set-timestamp-from-java/308812/1 "2022-07-04T11:55:45Z")

</div>

Hi,

i am using the elasticsearch-java-Client:

```auto
  	<dependency>
      <groupId>co.elastic.clients</groupId>
      <artifactId>elasticsearch-java</artifactId>
      <version>8.2.0</version>
    </dependency>

```

and connected to a Elastic-Server. Puting documents (we want to log from java) into ES works:

```auto
Logentry3 log = new Logentry3.Builder(message, level, this.anwendungsID, this.sessionID).addAll(optionale_Daten).build();
Request request = new Request("POST", indexname);
ObjectMapper mapper = new ObjectMapper(); // Jackson Json
request.setJsonEntity(mapper.writeValueAsString(log));
Response response = ct.restClient.performRequest(request);

```

ct is just a custom class from us where the connection is done and saved.  
Logentry3 is a custom class from us to hold:  
String message, log\_level status, int anwendungsID, int sessionID and a HashMap\<String, Object\>() optional\_data

Now we want to add time to allow kibana to display Dashboards within a specified begin and endtime. The system.currenttimeMillis() seems not to work for that.

Which Java-class do we need so save within the document?

Thanks

Enomine

---

<div class="post-metadata">

**Author:** ![Enomine](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@Enomine](https://discuss.elastic.co/u/Enomine)\
**Post date:** [July 4, 2022, 12:01pm UTC](https://discuss.elastic.co/t/how-to-set-timestamp-from-java/308812/2 "2022-07-04T12:01:37Z")

</div>

![Screenshot 2022-07-04 135948](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cd1adf691d2532e4a3be76a9321fd4ab4f4b3a39.png)

I think (but don't know for sure) that while creating a data view on Kibana -\> Stack Management -\> Data views  
i should be able to choose a Timestamp field if i did everything right.  
Currently i can not.

Thanks

Enomine

---

<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:** [August 1, 2022, 12:02pm UTC](https://discuss.elastic.co/t/how-to-set-timestamp-from-java/308812/3 "2022-08-01T12:02:37Z")

</div>

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