private Function<String, Instant> createRegularParser(final FieldSet fieldSet,
                                                       final DateTimeFormatterBuilder builder,
                                                       final ZoneId zoneId) {
        // Don't use the defaulting formatter if we can help it.
        if ((fieldSet.contains(YEAR) || fieldSet.contains(YEAR_OF_ERA))
            && fieldSet.contains(MONTH_OF_YEAR)
            && fieldSet.contains(DAY_OF_MONTH)) {
            final DateTimeFormatter formatter = builder.toFormatter(LOCALE);
            return new RegularParser(formatter, zoneId);

        } else {
            final ZonedDateTime referenceDateTime = getBaseTime().atZone(zoneId);

            builder.parseDefaulting(ChronoField.YEAR_OF_ERA, referenceDateTime.get(ChronoField.YEAR_OF_ERA));
            builder.parseDefaulting(ChronoField.MONTH_OF_YEAR, referenceDateTime.get(ChronoField.MONTH_OF_YEAR));
            builder.parseDefaulting(ChronoField.DAY_OF_MONTH, referenceDateTime.get(ChronoField.DAY_OF_MONTH));

            final DateTimeFormatter formatter = builder.toFormatter(LOCALE);

            return new RegularParserWithReferenceTime(fieldSet, formatter, zoneId, referenceDateTime);
        }
    }
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/ParseDateTime.java