WindmillTimeUtils { public static Instant windmillToHarnessTimestamp(long timestampUs) { Preconditions.checkArgument(timestampUs != Long.MIN_VALUE); Instant result = new Instant(divideAndRoundDown(timestampUs, 1000)); if (result.isAfter(BoundedWindow.TIMESTAMP_MAX_VALUE)) { return BoundedWindow.TIMESTAMP_MAX_VALUE; } return result; }  static @Nullable Instant windmillToHarnessWatermark(long watermarkUs); static Instant windmillToHarnessTimestamp(long timestampUs); static long harnessToWindmillTimestamp(Instant timestamp);  }
@Test public void testWindmillToHarnessTimestamp() { assertEquals(BoundedWindow.TIMESTAMP_MAX_VALUE, windmillToHarnessTimestamp(Long.MAX_VALUE)); assertEquals( BoundedWindow.TIMESTAMP_MAX_VALUE, windmillToHarnessTimestamp(Long.MAX_VALUE - 17)); assertEquals(new Instant(16), windmillToHarnessWatermark(16999)); assertEquals(new Instant(17), windmillToHarnessTimestamp(17120)); assertEquals(new Instant(17), windmillToHarnessTimestamp(17000)); assertEquals(new Instant(-17), windmillToHarnessTimestamp(-16987)); assertEquals(new Instant(-17), windmillToHarnessTimestamp(-17000)); assertEquals(new Instant(-18), windmillToHarnessTimestamp(-17001)); }