### Question:
LocalDateTimeConverter implements BytesConverter<LocalDateTime> { @Override public byte[] toBytes(LocalDateTime value) { byte[] date = longConverter.toBytes(value.toLocalDate().toEpochDay()); byte[] time = longConverter.toBytes(value.toLocalTime().toNanoOfDay()); byte [] datetime = new byte[date.length + time.length + 1]; datetime[0] = (byte)date.length; System.arraycopy(date,0, datetime, 1, date.length); System.arraycopy(time,0, datetime, date.length + 1, time.length); return datetime; } LocalDateTimeConverter(BytesConverter<Long> longConverter); @Override LocalDateTime fromBytes(byte[] bytes); @Override byte[] toBytes(LocalDateTime value); static final BytesConverter<LocalDateTime> INSTANCE; }### Answer:
@Test public void testToBytes() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.of(2015, 1, 7, 11, 0, 2)); assertArrayEquals(new byte[]{2, 64, 58, 0, 0, 36, 4, -113, 36, 116, 0}, bytes); }
@Test public void testToBytesBig() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.MAX); assertArrayEquals(new byte[]{8, 0, 0, 0, 85, 10, 27, 72, -9, 0, 0, 78, -108, -111, 78, -1, -1}, bytes); }
@Test public void testToBytesSmall() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.of(0, 1, 1, 0, 0, 0)); assertArrayEquals(new byte[]{4, -1, -11, 5, 88, 0}, bytes); }