quarkusio/quarkus · error · RuntimeException

One of 'format' or 'dateTimeFormatterProvider' must be set w

Error message

One of 'format' or 'dateTimeFormatterProvider' must be set when using '@DateFormat'

What it means

When @DateFormat is present, one of its two formatter sources must be configured: 'format' or 'dateTimeFormatterProvider'. If neither is set, the annotation is inert and RESTEasy Reactive fails deployment with this RuntimeException.

Source

Thrown at independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/ServerEndpointIndexer.java:631

                dateTimeFormatterProviderClassName = dateTimeFormatterProviderValue.asClass().name().toString();
            }
        }

        if (INSTANT.equals(paramType)) {
            if (dateFormatInstance != null) {
                throw new RuntimeException(contextualizeErrorMessage(
                        "'java.time.Instant' types must not be annotated with '@DateFormat'",
                        currentMethodInfo));
            }
            return new InstantParamConverter.Supplier();
        }

        if ((format != null) && (dateTimeFormatterProviderClassName != null)) {
            throw new RuntimeException(contextualizeErrorMessage(
                    "Using both 'format' and 'dateTimeFormatterProvider' is not allowed when using '@DateFormat'",
                    currentMethodInfo));
        } else if ((format == null) && (dateTimeFormatterProviderClassName == null) && (dateFormatInstance != null)) {
            throw new RuntimeException(contextualizeErrorMessage(
                    "One of 'format' or 'dateTimeFormatterProvider' must be set when using '@DateFormat'", currentMethodInfo));
        }

        if (LOCAL_DATE.equals(paramType)) {
            return new LocalDateParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (LOCAL_DATE_TIME.equals(paramType)) {
            return new LocalDateTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (LOCAL_TIME.equals(paramType)) {
            return new LocalTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (OFFSET_DATE_TIME.equals(paramType)) {
            return new OffsetDateTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (OFFSET_TIME.equals(paramType)) {
            return new OffsetTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (ZONED_DATE_TIME.equals(paramType)) {
            return new ZonedDateTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (YEAR.equals(paramType)) {
            return new YearParamConverter.Supplier(format, dateTimeFormatterProviderClassName);
        } else if (YEAR_MONTH.equals(paramType)) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set either format = "pattern" or dateTimeFormatterProvider = YourProvider.class.
  2. Remove @DateFormat entirely if default ISO parsing is fine.
  3. If a default pattern was intended, set it explicitly.

Example fix

// before
@DateFormat
@QueryParam("date")
LocalDate date;

// after
@DateFormat(format = "yyyy-MM-dd")
@QueryParam("date")
LocalDate date;
Defensive patterns

Strategy: validation

Validate before calling

DateFormat df = field.getAnnotation(DateFormat.class);
if (df != null && df.format().isEmpty()
    && (df.dateTimeFormatterProvider() == void.class || df.dateTimeFormatterProvider() == null)) {
    throw new IllegalStateException("@DateFormat requires format or dateTimeFormatterProvider");
}

Prevention

When it happens

Trigger: A bare @DateFormat (no attributes) on a LocalDateTime/LocalDate/OffsetDateTime/etc. parameter.

Common situations: Adding @DateFormat as a marker assuming defaults; removing the format value during refactoring; template-generated annotations left blank.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/9c5b1d0d23cb56c1. Report an issue: GitHub.