Skip to content

Commit

Permalink
feat: add possibility to get time from Point (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Sep 15, 2022
1 parent a5d9a27 commit f377905
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 6.6.0 [unreleased]

### Features
1. [#419](https://github.com/influxdata/influxdb-client-java/pull/419): Add possibility to get time from `Point` data structure

### Documentation
1. [#406](https://github.com/influxdata/influxdb-client-java/pull/406): Fix compatibility of the `doclint` between JDK 8 and JDK 18

Expand Down
8 changes: 8 additions & 0 deletions client/src/main/java/com/influxdb/client/write/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ public Point time(@Nullable final Long time, @Nonnull final WritePrecision preci
return time((Number) time, precision);
}

/**
* @return the data point timestamp
*/
@Nullable
public Number getTime() {
return time;
}

/**
* @return the data point precision
*/
Expand Down
13 changes: 13 additions & 0 deletions client/src/test/java/com/influxdb/client/write/PointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,19 @@ void timeInstantNull() {
Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=2i");
}

@Test
void timeGetTime() {

Instant time = Instant.parse("2022-06-12T10:26:03.800123456Z");

Point point = Point.measurement("h2o")
.addTag("location", "europe")
.addField("level", 2)
.time(time, WritePrecision.NS);

Assertions.assertThat(point.getTime()).isEqualTo(BigInteger.valueOf(1655029563800123456L));
}

@Test
void defaultTags() {

Expand Down

0 comments on commit f377905

Please sign in to comment.