@Test public void nanosecondPrecision() { PreciseTimestampFormatter formatter = new PreciseTimestampFormatter("HH:mm:ss.SSSSSSSSS", Locale.US); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 55, 1))).isEqualTo("12:30:55.000000001"); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 55, 999_999_999))).isEqualTo("12:30:55.999999999"); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 56, 0))).isEqualTo("12:30:56.000000000"); }
@Override public String format(final Timestamp timestamp) { Instant instant = timestamp.toInstant(); return truncationUnit == null ? formatter.format(instant) : format(instant.truncatedTo(truncationUnit)); }
PreciseTimestampFormatter implements TimestampFormatter { @Override public String format(final Timestamp timestamp) { Instant instant = timestamp.toInstant(); return truncationUnit == null ? formatter.format(instant) : format(instant.truncatedTo(truncationUnit)); } }
PreciseTimestampFormatter implements TimestampFormatter { @Override public String format(final Timestamp timestamp) { Instant instant = timestamp.toInstant(); return truncationUnit == null ? formatter.format(instant) : format(instant.truncatedTo(truncationUnit)); } PreciseTimestampFormatter(final String pattern, final Locale locale); }
PreciseTimestampFormatter implements TimestampFormatter { @Override public String format(final Timestamp timestamp) { Instant instant = timestamp.toInstant(); return truncationUnit == null ? formatter.format(instant) : format(instant.truncatedTo(truncationUnit)); } PreciseTimestampFormatter(final String pattern, final Locale locale); @Override boolean isValid(final String timestamp); @Override String format(final Timestamp timestamp); }
PreciseTimestampFormatter implements TimestampFormatter { @Override public String format(final Timestamp timestamp) { Instant instant = timestamp.toInstant(); return truncationUnit == null ? formatter.format(instant) : format(instant.truncatedTo(truncationUnit)); } PreciseTimestampFormatter(final String pattern, final Locale locale); @Override boolean isValid(final String timestamp); @Override String format(final Timestamp timestamp);  }