### Question:
LocalDateTimeConverter implements BytesConverter<LocalDateTime> { @Override public LocalDateTime fromBytes(byte[] bytes) { if (bytes.length < 2) { throw new IllegalArgumentException("Unexpected number of bytes: " + bytes.length); } int dateLength = bytes[0]; if(dateLength <= 0 || dateLength >= bytes.length - 1) { throw new CayenneCryptoException("Corrupted data for LocalDateTime: wrong encoded length"); } int timeLength = bytes.length - 1 - dateLength; byte[] date = new byte[dateLength]; byte[] time = new byte[timeLength]; System.arraycopy(bytes, 1, date, 0, dateLength); System.arraycopy(bytes, dateLength + 1, time, 0, timeLength); LocalDate localDate = LocalDate.ofEpochDay(longConverter.fromBytes(date)); LocalTime localTime = LocalTime.ofNanoOfDay(longConverter.fromBytes(time)); return LocalDateTime.of(localDate, localTime); } LocalDateTimeConverter(BytesConverter<Long> longConverter); @Override LocalDateTime fromBytes(byte[] bytes); @Override byte[] toBytes(LocalDateTime value); static final BytesConverter<LocalDateTime> INSTANCE; }### Answer:
@Test public void testFromBytes() { assertEquals(LocalDateTime.of(2015, 1, 7, 11, 0, 2), LocalDateTimeConverter.INSTANCE.fromBytes(new byte[]{2, 64, 58, 0, 0, 36, 4, -113, 36, 116, 0})); }
@Test public void testFromBytesBig() { LocalDateTime localDateTime = LocalDateTimeConverter.INSTANCE .fromBytes(new byte[]{8, 0, 0, 0, 85, 10, 27, 72, -9, 0, 0, 78, -108, -111, 78, -1, -1}); assertEquals(LocalDateTime.MAX, localDateTime); }
@Test public void testFromBytesSmall() { LocalDateTime localDateTime = LocalDateTimeConverter.INSTANCE .fromBytes(new byte[]{4, -1, -11, 5, 88, 0}); assertEquals(LocalDateTime.of(0, 1, 1, 0, 0, 0), localDateTime); }