public static Field randomDateTimeField(final String name,
                                            final LocalDateTime startDateInc,
                                            final LocalDateTime endDateExc,
                                            final DateTimeFormatter formatter) {
        try {
            Objects.requireNonNull(startDateInc);
            Objects.requireNonNull(endDateExc);
            Objects.requireNonNull(formatter);
            Utils.checkArgument(
                    endDateExc.isAfter(startDateInc),
                    "endDateExc [{}] must be after startDateInc [{}]",
                    endDateExc,
                    startDateInc);

            final long millisBetween = endDateExc.toInstant(ZoneOffset.UTC).toEpochMilli()
                                       - startDateInc.toInstant(ZoneOffset.UTC).toEpochMilli();

            final ValueFunction valueFunction = (random, ignoredFaker) -> {
                try {
                    final long randomDelta = (long) (random.nextDouble() * millisBetween);
                    final LocalDateTime dateTime = startDateInc.plus(randomDelta, ChronoUnit.MILLIS);
                    return dateTime.format(formatter);
                } catch (Exception e) {
                    throw new RuntimeException(Utils.message("Time range is too large, maximum allowed: {}",
                            Duration.ofMillis(Integer.MAX_VALUE).toString()), e);
                }
            };
            return new Field(name, valueFunction);
        } catch (Exception e) {
            throw new RuntimeException(Utils.message("Error building randomDateTimeField, {}, {}",
                    name,
                    e.getMessage()), e);
        }
    }
A field to produce a sequence of random datetime values within a defined time range.
The formatter controls the output format.

@param name         Field name for use in the header
@param startDateInc The start date for the random times (inclusive)
@param endDateExc   The end date of random times (exclusive)
@param formatter    {@link DateTimeFormatter} to use
@return A complete {@link Field}
stroom-test-common/src/main/java/stroom/test/common/data/DataGenerator.java