public static LocalDateTime readDateTime64(ClickHouseInputStream input, int scale, TimeZone tz) throws IOException {
        long value = readInt64(input);
        int nanoSeconds = 0;
        if (ClickHouseChecker.between(scale, ClickHouseValues.PARAM_SCALE, 0, 9) > 0) {
            int factor = BASES[scale];
            nanoSeconds = (int) (value % factor);
            value /= factor;
            if (nanoSeconds < 0) {
                nanoSeconds += factor;
                value--;
            }
            if (nanoSeconds > 0L) {
                nanoSeconds *= BASES[9 - scale];
            }
        }

        return LocalDateTime.ofInstant(Instant.ofEpochSecond(value, nanoSeconds),
                tz != null ? tz.toZoneId() : ClickHouseValues.UTC_ZONE);
    }
Read {@link java.time.LocalDateTime} from given input stream.

@param input non-null input stream
@param scale scale of the datetime
@param tz    time zone, null is treated as UTC
@return local datetime
@throws IOException when failed to read value from input stream or reached
                    end of the stream
clickhouse-data/src/main/java/com/clickhouse/data/format/BinaryStreamUtils.java