LegacyTimestamp implements Timestamp { @Override public long calcDifferenceInNanoseconds(final Timestamp other) { return (date.getTime() - other.toDate().getTime()) * MILLISECOND_IN_NANOS; } LegacyTimestamp();  LegacyTimestamp(final long milliseconds); @Override Date toDate(); @IgnoreJRERequirement @Override Instant toInstant(); @Override java.sql.Timestamp toSqlTimestamp(); @Override long calcDifferenceInNanoseconds(final Timestamp other);  }
@Test public void calcDifferenceInNanoseconds() { LegacyTimestamp first = create(LocalDate.of(1985, 6, 3), LocalTime.of(12, 30, 50, 500_000_000)); LegacyTimestamp second = create(LocalDate.of(1985, 6, 3), LocalTime.of(14, 33, 54, 505_000_000)); long nanoseconds = second.calcDifferenceInNanoseconds(first); assertThat(nanoseconds).isEqualTo((((2L * 60L + 3) * 60L + 4L) * 1000L + 5L) * 1_000_000L); }