@Override
    public void write(final MySQLPacketPayload payload, final Object value) {
        LocalDateTime dateTime = value instanceof LocalDateTime ? (LocalDateTime) value : new Timestamp(((Date) value).getTime()).toLocalDateTime();
        int year = dateTime.getYear();
        int month = dateTime.getMonthValue();
        int dayOfMonth = dateTime.getDayOfMonth();
        int hours = dateTime.getHour();
        int minutes = dateTime.getMinute();
        int seconds = dateTime.getSecond();
        int nanos = dateTime.getNano();
        boolean isTimeAbsent = 0 == hours && 0 == minutes && 0 == seconds;
        boolean isNanosAbsent = 0 == nanos;
        if (isTimeAbsent && isNanosAbsent) {
            payload.writeInt1(4);
            writeDate(payload, year, month, dayOfMonth);
            return;
        }
        if (isNanosAbsent) {
            payload.writeInt1(7);
            writeDate(payload, year, month, dayOfMonth);
            writeTime(payload, hours, minutes, seconds);
            return;
        }
        payload.writeInt1(11);
        writeDate(payload, year, month, dayOfMonth);
        writeTime(payload, hours, minutes, seconds);
        writeNanos(payload, nanos);
    }
@Test
    void assertWriteLocalDateTimeTypeSevenBytes() {
        MySQLDateBinaryProtocolValue actual = new MySQLDateBinaryProtocolValue();
        actual.write(payload, LocalDateTime.of(1970, 1, 14, 12, 10, 30));
        verify(payload).writeInt1(7);
        verify(payload).writeInt2(1970);
        verify(payload).writeInt1(1);
        verify(payload).writeInt1(14);
        verify(payload).writeInt1(12);
        verify(payload).writeInt1(10);
        verify(payload).writeInt1(30);
    }