private static ZonedDateTime parseBest(final String value, final DateTimeFormatter formatter, final ZoneId zoneId) {
        final TemporalAccessor temporalAccessor = formatter.parseBest(value,
                ZonedDateTime::from,
                LocalDateTime::from,
                LocalDate::from);
        if (temporalAccessor instanceof ZonedDateTime) {
            return ((ZonedDateTime) temporalAccessor).withZoneSameInstant(zoneId);
        }
        if (temporalAccessor instanceof LocalDateTime) {
            return ((LocalDateTime) temporalAccessor).atZone(zoneId);
        }
        return ((LocalDate) temporalAccessor).atStartOfDay(zoneId);
    }
Parsing dates that use week fields has to be done differently as week based parsing does not seem to
cope with conflicting default values for fields.
stroom-pipeline/src/main/java/stroom/pipeline/xsltfunctions/FormatDate.java