public static long parseDate(final String pattern, final String timeZoneId, final String value) {
        ZoneId dateTimeZone = null;
        ZonedDateTime dateTime = null;

        if (value == null || value.trim().length() == 0) {
            throw new IllegalArgumentException("Unable to parse date: \"" + value + '"');
        }

        // Try to parse the time zone first.
        try {
            if (timeZoneId != null) {
                if (GMT_BST_GUESS.equals(timeZoneId)) {
                    dateTimeZone = EUROPE_LONDON_TIME_ZONE;
                } else {
                    dateTimeZone = ZoneId.of(timeZoneId);
                }
            }
        } catch (final IllegalArgumentException e) {
            LOGGER.debug("Unable to parse time zone!", e);
        }

        if (dateTimeZone == null) {
            dateTimeZone = ZoneOffset.UTC;
        }

        final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(pattern, Locale.ENGLISH);
        try {
            dateTime = parse(dateFormat, value, dateTimeZone);

        } catch (final IllegalArgumentException e) {
            LOGGER.debug("Unable to parse date!", e);

            // We failed to use the time zone so try UTC.
            dateTime = parse(dateFormat, value, ZoneOffset.UTC);
        }

        if (dateTime == null) {
            throw new IllegalArgumentException("Unable to parse date: \"" + value + '"');
        }

        return dateTime.toInstant().toEpochMilli();
    }
Parse a date using a format.

@param pattern    pattern to match
@param timeZoneId if provided the pattern will append Z and the time zone will
                  be added
@param value      value to parse
@return the result
@throws IllegalArgumentException if date does not parse
stroom-legacy/stroom-legacy-model_6_1/src/main/java/stroom/legacy/model_6_1/DateUtil.java