TimestampMeasurementElement implements MeasurementElement, Serializable { public ZonedDateTime asZonedDateTime() { return ZonedDateTime.ofInstant(Instant.ofEpochMilli(this.value), ZoneOffset.UTC); } TimestampMeasurementElement(final long value);  TimestampMeasurementElement(final ZonedDateTime zonedDateTime); Long getValue(); ZonedDateTime asZonedDateTime(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void AsZonedDateTimeShouldReturnCorrectZonedDateTimeWhenConstructedUsingTimestamp() { final ZonedDateTime expected = ZonedDateTime.of(2020, 2, 20, 21, 59, 59, 0, ZoneOffset.UTC); final long timestamp = expected.toInstant().toEpochMilli(); final TimestampMeasurementElement element = new TimestampMeasurementElement(timestamp); final ZonedDateTime actual = element.asZonedDateTime(); assertThat(actual).isEqualTo(expected); }
@Test public void AsZonedDateTimeShouldReturnCorrectZonedDateTimeWhenConstructedUsingZonedDateTime() { final ZonedDateTime expected = ZonedDateTime.of(2020, 2, 20, 21, 59, 59, 0, ZoneOffset.UTC); final TimestampMeasurementElement element = new TimestampMeasurementElement(expected); final ZonedDateTime actual = element.asZonedDateTime(); assertThat(actual).isEqualTo(expected); }