public static Timestamp next(Timestamp timestamp) {
    if (timestamp.equals(Timestamp.MAX_VALUE)) {
      return timestamp;
    }

    final int nanos = timestamp.getNanos();
    final long seconds = timestamp.getSeconds();
    if (nanos + 1 >= NANOS_PER_SECOND) {
      return Timestamp.ofTimeSecondsAndNanos(seconds + 1, 0);
    } else {
      return Timestamp.ofTimeSecondsAndNanos(seconds, nanos + 1);
    }
  }
@Test
  public void testNextReturnsMaxWhenTimestampIsAlreadyMax() {
    assertEquals(Timestamp.MAX_VALUE, TimestampUtils.next(Timestamp.MAX_VALUE));
  }