{"record":{"id":"2cdf42c211c54ef0","repo":"junit-team/junit5","slug":"defaulttimezone-not-configured-correctly-could-n","errorCode":null,"errorMessage":"@DefaultTimeZone not configured correctly.\nCould not find the specified time zone + '%s'.\nPlease use correct identifiers, e.g. \"GMT\" for Greenwich Mean Time.","messagePattern":"@DefaultTimeZone not configured correctly\\.\nCould not find the specified time zone \\+ '(.+?)'\\.\nPlease use correct identifiers, e\\.g\\. \"GMT\" for Greenwich Mean Time\\.","errorType":"exception","errorClass":"ExtensionConfigurationException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-api/src/main/java/org/junit/jupiter/api/util/DefaultTimeZoneExtension.java","lineNumber":83,"sourceCode":"\t\t\treturn createTimeZoneFromProvider(annotation.timeZoneProvider());\n\t\t}\n\t}\n\n\tprivate static void validateCorrectConfiguration(DefaultTimeZone annotation) {\n\t\tboolean noValue = annotation.value().isEmpty();\n\t\tboolean noProvider = annotation.timeZoneProvider() == NullTimeZoneProvider.class;\n\t\tif (noValue == noProvider) {\n\t\t\tthrow new ExtensionConfigurationException(\n\t\t\t\t\"Either a valid time zone id or a TimeZoneProvider must be provided to \"\n\t\t\t\t\t\t+ DefaultTimeZone.class.getSimpleName());\n\t\t}\n\t}\n\n\tprivate static TimeZone createTimeZoneFromZoneId(String timeZoneId) {\n\t\tTimeZone configuredTimeZone = TimeZone.getTimeZone(timeZoneId);\n\t\t// TimeZone::getTimeZone returns with GMT as fallback if the given ID cannot be understood\n\t\tif (configuredTimeZone.equals(TimeZone.getTimeZone(\"GMT\")) && !\"GMT\".equals(timeZoneId)) {\n\t\t\tthrow new ExtensionConfigurationException(\"\"\"\n\t\t\t\t\t@DefaultTimeZone not configured correctly.\n\t\t\t\t\tCould not find the specified time zone + '%s'.\n\t\t\t\t\tPlease use correct identifiers, e.g. \"GMT\" for Greenwich Mean Time.\n\t\t\t\t\t\"\"\".formatted(timeZoneId));\n\t\t}\n\t\treturn configuredTimeZone;\n\t}\n\n\tprivate static TimeZone createTimeZoneFromProvider(Class<? extends TimeZoneProvider> providerClass) {\n\t\ttry {\n\t\t\tTimeZoneProvider provider = ReflectionSupport.newInstance(providerClass);\n\t\t\treturn Optional.ofNullable(provider.get()).orElse(TimeZone.getTimeZone(\"GMT\"));\n\t\t}\n\t\tcatch (Exception exception) {\n\t\t\tthrow new ExtensionConfigurationException(\"Could not instantiate TimeZoneProvider because of exception\",\n\t\t\t\texception);\n\t\t}\n\t}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/util/DefaultTimeZoneExtension.java#L65-L101","documentation":"ExtensionConfigurationException from DefaultTimeZoneExtension.createTimeZoneFromZoneId, thrown when the supplied zone id is unrecognized. Because TimeZone.getTimeZone silently falls back to GMT for unknown ids, JUnit explicitly checks: if the resolved zone equals GMT but the requested id was not literally \"GMT\", the id is treated as invalid and rejected.","triggerScenarios":"Annotating with @DefaultTimeZone(\"US/Eastern\") (Java uses \"America/New_York\" — wrong id), or a typo like @DefaultTimeZone(\"UTSC\"), or any string TimeZone.getTimeZone cannot map. The equals-GMT-but-not-GMT branch fires.","commonSituations":"Using the legacy three-letter ids (\"EST\", \"PST\") which are deprecated/ambiguous; typos; copying an IANA id that the JVM's tz database doesn't have; regional shorthand that isn't a real zone.","solutions":["Use a valid IANA zone id, e.g. \"America/New_York\", \"Europe/Berlin\", \"UTC\".","Confirm the id via java.time.ZoneId.getAvailableZoneIds() if unsure.","Avoid deprecated three-letter ids; prefer the canonical IANA names."],"exampleFix":"// before\n@DefaultTimeZone(\"EST\")\nvoid test() {}\n// after\n@DefaultTimeZone(\"America/New_York\")\nvoid test() {}","handlingStrategy":"validation","validationCode":"String id = annotation.value();\nif (!ZoneId.getAvailableZoneIds().contains(id)) { /* not a valid IANA id */ }","typeGuard":"static boolean isValidZoneId(String id) {\n    return ZoneId.getAvailableZoneIds().contains(id);\n}","tryCatchPattern":null,"preventionTips":["Use canonical IANA zone ids (e.g. America/New_York, Europe/Berlin, UTC).","Avoid deprecated three-letter ids (EST, PST).","Cross-check with java.time.ZoneId.getAvailableZoneIds() when unsure."],"tags":["default-timezone","invalid-zone-id","iana-tz","extension-config"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}