static long toMillis(long timestamp) {
    if (timestamp < 10000000000L) {
      // in seconds
      return timestamp * 1000;
    } else if (timestamp < 10000000000000L) {
      // in millis
      return timestamp;
    }
    // in micros
    return timestamp / 1000;
  }
@TestTemplate
  public void testToMillis() {
    long millis = 1542750947417L;
    assertThat(toMillis(millis / 1000)).isEqualTo(1542750947000L);
    assertThat(toMillis(millis)).isEqualTo(1542750947417L);
    assertThat(toMillis(millis * 1000 + 918)).isEqualTo(1542750947417L);
  }