TimestampToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { builder.append(getTime(logEntry)); } TimestampToken();   TimestampToken(final String unit); @Override Collection<LogEntryValue> getRequiredLogEntryValues(); @Override void render(final LogEntry logEntry, final StringBuilder builder); @Override void apply(final LogEntry logEntry, final PreparedStatement statement, final int index);  }
@Test public void renderSecondsPattern() { TimestampToken token = new TimestampToken("seconds"); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 0, 0, 0))).isEqualTo("1467288000"); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 15, 1, 987654321))).isEqualTo("1467288901"); }
@Test public void renderMillisecondsPattern() { TimestampToken token = new TimestampToken("milliseconds"); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 0, 0, 0))).isEqualTo("1467288000000"); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 15, 1, 987654321))).isEqualTo("1467288901987"); }
@Test public void renderDefaultPattern() { TimestampToken token = new TimestampToken(); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 0, 0, 0))).isEqualTo("1467288000"); assertThat(render(token, LocalDateTime.of(2016, 6, 30, 12, 15, 1, 987654321))).isEqualTo("1467288901"); }