@Test public void minutePrecision() { PreciseTimestampFormatter formatter = new PreciseTimestampFormatter("yyyy-MM-dd HH:mm", Locale.US); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 55, 0))).isEqualTo("2016-02-01 12:30"); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 55, 999_000_000))).isEqualTo("2016-02-01 12:30"); assertThat(formatter.format(TimestampFactory.create(2016, 2, 1, 12, 30, 56, 0))).isEqualTo("2016-02-01 12:30"); }
@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);  }