@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); }
@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 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 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); }
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); }
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; }