public static DateTime convertToDateTime(@Nonnull Object value) {
        if (value instanceof DateTime) {
            return (DateTime) value;
        }

        if (value instanceof Date) {
            return new DateTime(value, DateTimeZone.UTC);
        } else if (value instanceof ZonedDateTime) {
            final DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(TimeZone.getTimeZone(((ZonedDateTime) value).getZone()));
            return new DateTime(Date.from(((ZonedDateTime) value).toInstant()), dateTimeZone);
        } else if (value instanceof OffsetDateTime) {
            return new DateTime(Date.from(((OffsetDateTime) value).toInstant()), DateTimeZone.UTC);
        } else if (value instanceof LocalDateTime) {
            final LocalDateTime localDateTime = (LocalDateTime) value;
            final ZoneId defaultZoneId = ZoneId.systemDefault();
            final ZoneOffset offset = defaultZoneId.getRules().getOffset(localDateTime);
            return new DateTime(Date.from(localDateTime.toInstant(offset)));
        } else if (value instanceof LocalDate) {
            final LocalDate localDate = (LocalDate) value;
            final LocalDateTime localDateTime = localDate.atStartOfDay();
            final ZoneId defaultZoneId = ZoneId.systemDefault();
            final ZoneOffset offset = defaultZoneId.getRules().getOffset(localDateTime);
            return new DateTime(Date.from(localDateTime.toInstant(offset)));
        } else if (value instanceof Instant) {
            return new DateTime(Date.from((Instant) value), DateTimeZone.UTC);
        } else if (value instanceof String) {
            return ES_DATE_FORMAT_FORMATTER.parseDateTime((String) value);
        } else {
            throw new IllegalArgumentException("Value of invalid type <" + value.getClass().getSimpleName() + "> provided");
        }
    }
@Test
    void convertFromInvalidType() {
        assertThatThrownBy(() -> DateTimeConverter.convertToDateTime(1234))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessage("Value of invalid type <Integer> provided");
    }