{"record":{"id":"9f67f6a94793eb39","repo":"quarkusio/quarkus","slug":"using-both-format-and-datetimeformatterprovider","errorCode":null,"errorMessage":"Using both 'format' and 'dateTimeFormatterProvider' is not allowed when using '@DateFormat'","messagePattern":"Using both 'format' and 'dateTimeFormatterProvider' is not allowed when using '@DateFormat'","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/ServerEndpointIndexer.java","lineNumber":627,"sourceCode":"            }\n\n            AnnotationValue dateTimeFormatterProviderValue = dateFormatInstance.value(\"dateTimeFormatterProvider\");\n            if (dateTimeFormatterProviderValue != null) {\n                dateTimeFormatterProviderClassName = dateTimeFormatterProviderValue.asClass().name().toString();\n            }\n        }\n\n        if (INSTANT.equals(paramType)) {\n            if (dateFormatInstance != null) {\n                throw new RuntimeException(contextualizeErrorMessage(\n                        \"'java.time.Instant' types must not be annotated with '@DateFormat'\",\n                        currentMethodInfo));\n            }\n            return new InstantParamConverter.Supplier();\n        }\n\n        if ((format != null) && (dateTimeFormatterProviderClassName != null)) {\n            throw new RuntimeException(contextualizeErrorMessage(\n                    \"Using both 'format' and 'dateTimeFormatterProvider' is not allowed when using '@DateFormat'\",\n                    currentMethodInfo));\n        } else if ((format == null) && (dateTimeFormatterProviderClassName == null) && (dateFormatInstance != null)) {\n            throw new RuntimeException(contextualizeErrorMessage(\n                    \"One of 'format' or 'dateTimeFormatterProvider' must be set when using '@DateFormat'\", currentMethodInfo));\n        }\n\n        if (LOCAL_DATE.equals(paramType)) {\n            return new LocalDateParamConverter.Supplier(format, dateTimeFormatterProviderClassName);\n        } else if (LOCAL_DATE_TIME.equals(paramType)) {\n            return new LocalDateTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);\n        } else if (LOCAL_TIME.equals(paramType)) {\n            return new LocalTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);\n        } else if (OFFSET_DATE_TIME.equals(paramType)) {\n            return new OffsetDateTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);\n        } else if (OFFSET_TIME.equals(paramType)) {\n            return new OffsetTimeParamConverter.Supplier(format, dateTimeFormatterProviderClassName);\n        } else if (ZONED_DATE_TIME.equals(paramType)) {","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/ServerEndpointIndexer.java#L609-L645","documentation":"@DateFormat accepts either a built-in 'format' pattern or a 'dateTimeFormatterProvider' class supplying a custom DateTimeFormatter — never both, as that is ambiguous. When both attributes are set, deployment fails with this RuntimeException.","triggerScenarios":"@DateFormat(format = \"yyyy-MM-dd\", dateTimeFormatterProvider = MyProvider.class) on a temporal parameter (LocalDate, LocalDateTime, OffsetDateTime, etc.).","commonSituations":"Migrating from a pattern to a provider and forgetting to delete 'format'; copy-pasting annotated parameters and adding a second attribute.","solutions":["Keep only one attribute: delete 'format' if using a provider, or delete 'dateTimeFormatterProvider' if using the pattern.","Rely on the provider alone if it encapsulates the pattern.","Rebuild and run a startup test — the error only surfaces at deployment."],"exampleFix":"// before\n@DateFormat(format = \"yyyy-MM-dd\", dateTimeFormatterProvider = AppDateFormatter.class)\n@QueryParam(\"from\")\nLocalDate from;\n\n// after\n@DateFormat(dateTimeFormatterProvider = AppDateFormatter.class)\n@QueryParam(\"from\")\nLocalDate from;","handlingStrategy":"validation","validationCode":"DateFormat df = field.getAnnotation(DateFormat.class);\nif (df != null && !df.format().isEmpty()\n    && df.dateTimeFormatterProvider() != void.class && df.dateTimeFormatterProvider() != null) {\n    throw new IllegalStateException(\"Use either format or dateTimeFormatterProvider, not both\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one style (pattern OR provider) as a team standard.","Add a test scanning for invalid @DateFormat combinations.","Document valid attribute combinations."],"tags":["resteasy-reactive","quarkus","java-time","dateformat","configuration-conflict","deployment-failure"],"backgroundTag":"invalid-dateformat-annotation-usage","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}