MySQLTimestampBinlogProtocolValue implements MySQLBinlogProtocolValue { @Override public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) { int seconds = payload.readInt4(); return 0 == seconds ? MySQLTimeValueUtil.DATETIME_OF_ZERO : MySQLTimeValueUtil.getSimpleDateFormat().format(new Timestamp(seconds * 1000L)); }  @Override Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload);  }
@Test public void assertRead() { int currentSeconds = new Long(System.currentTimeMillis() / 1000).intValue(); when(payload.readInt4()).thenReturn(currentSeconds); assertThat(new MySQLTimestampBinlogProtocolValue().read(columnDef, payload), is(MySQLTimeValueUtil.getSimpleDateFormat().format(new Timestamp(currentSeconds * 1000L)))); }
@Test public void assertReadNullTime() { when(payload.readInt4()).thenReturn(0); assertThat(new MySQLTimestampBinlogProtocolValue().read(columnDef, payload), is(MySQLTimeValueUtil.DATETIME_OF_ZERO)); }