public static BigDecimal toNanos(Timestamp timestamp) {
    final BigDecimal secondsAsNanos =
        BigDecimal.valueOf(timestamp.getSeconds()).subtract(MIN_SECONDS).scaleByPowerOfTen(9);
    final BigDecimal nanos = BigDecimal.valueOf(timestamp.getNanos());

    return secondsAsNanos.add(nanos);
  }
@Test
  public void testToNanosConvertTimestampMaxToNanos() {
    assertEquals(
        new BigDecimal("315537897599999999999"), TimestampUtils.toNanos(Timestamp.MAX_VALUE));
  }