{"record":{"id":"dabeef522441b456","repo":"jeecgboot/JeecgBoot","slug":"support-for-specifying-both-a-day-of-week-and-a-da","errorCode":null,"errorMessage":"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.","messagePattern":"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented\\.","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java","lineNumber":524,"sourceCode":"            if (exprOn <= DAY_OF_WEEK) {\n                throw new ParseException(\"Unexpected end of expression.\",\n                        expression.length());\n            }\n\n            if (exprOn <= YEAR) {\n                storeExpressionVals(0, \"*\", YEAR);\n            }\n\n            TreeSet<Integer> dow = getSet(DAY_OF_WEEK);\n            TreeSet<Integer> dom = getSet(DAY_OF_MONTH);\n\n            // Copying the logic from the UnsupportedOperationException below\n            boolean dayOfMSpec = !dom.contains(NO_SPEC);\n            boolean dayOfWSpec = !dow.contains(NO_SPEC);\n\n            if (!dayOfMSpec || dayOfWSpec) {\n                if (!dayOfWSpec || dayOfMSpec) {\n                    throw new ParseException(\n                            \"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.\", 0);\n                }\n            }\n        } catch (ParseException pe) {\n            throw pe;\n        } catch (Exception e) {\n            throw new ParseException(\"Illegal cron expression format (\"\n                    + e + \")\", 0);\n        }\n    }\n\n    protected int storeExpressionVals(int pos, String s, int type)\n            throws ParseException {\n\n        int incr = 0;\n        int i = skipWhiteSpace(pos, s);\n        if (i >= s.length()) {\n            return i;","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java#L506-L542","documentation":"Thrown by CronExpression's parser when both day-of-month and day-of-week fields are specified with actual values (neither is '?'/NO_SPEC). Quartz requires that one of these two fields be '?' (no specific value) because the semantics of specifying both is ambiguous and not supported. The parser checks: if day-of-month is specified AND day-of-week is specified, it throws. The '?' character tells Quartz to ignore that field.","triggerScenarios":"Cron expression like '0 0 12 15 * 1' where both day-of-month (15) and day-of-week (1/Monday) are specified. Expression like '0 0 12 * * 1-5' is fine (dom is '*'), but '0 0 12 1-31 * 1-5' is not (both dom and dow have explicit ranges, and neither is '?'). Expression like '0 0 12 15 * MON' triggers the error.","commonSituations":"Users familiar with standard Unix cron (which allows specifying both dom and dow as an OR condition) transitioning to Quartz cron (which does not). Forgetting to use '?' for the unused day field. Copying expressions from Unix cron documentation directly into a Quartz-based scheduler like XXL-Job.","solutions":["If you want to trigger on a specific day of the month regardless of weekday, use '?' for day-of-week: '0 0 12 15 * ?'.","If you want to trigger on specific weekdays regardless of the date, use '?' for day-of-month: '0 0 12 ? * MON-FRI'.","If you need both conditions (e.g., '15th of month AND it's a Monday'), use two separate triggers and filter in your job logic, or use a single trigger with broader scope and check the condition in the job.","Remember: '*' in day-of-month or day-of-week counts as 'specified' — you must use '?' to mark a field as 'no value'."],"exampleFix":"// before: both dom and dow specified — invalid\nString cron = \"0 0 12 15 * MON\";\nCronExpression expr = new CronExpression(cron);\n\n// after: use '?' for the field you don't care about\n// Option 1: trigger on the 15th of every month (any weekday)\nString cron1 = \"0 0 12 15 * ?\";\n// Option 2: trigger every Monday (any date)\nString cron2 = \"0 0 12 ? * MON\";\nCronExpression expr = new CronExpression(cron1);","handlingStrategy":"validation","validationCode":"// Pre-validate that day-of-month and day-of-week are not both specified\npublic void validateDomDowExclusion(String expression) {\n    String[] fields = expression.trim().split(\"\\\\s+\");\n    if (fields.length < 6) return; // Let field-count validation handle this\n    String dom = fields[3]; // day-of-month\n    String dow = fields[5]; // day-of-week\n    boolean domSpecified = !\"?\".equals(dom);\n    boolean dowSpecified = !\"?\".equals(dow);\n    if (domSpecified && dowSpecified) {\n        throw new IllegalArgumentException(\n            \"Cannot specify both day-of-month ('\" + dom + \"') and day-of-week ('\" + dow +\n            \"'). Use '?' for the field you want to ignore.\");\n    }\n}","typeGuard":"// Check if at least one of dom/dow is '?'\npublic boolean hasValidDomDowExclusion(String expression) {\n    String[] fields = expression.trim().split(\"\\\\s+\");\n    if (fields.length < 6) return false;\n    String dom = fields[3];\n    String dow = fields[5];\n    return \"?\".equals(dom) || \"?\".equals(dow);\n}","tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expression);\n} catch (ParseException e) {\n    if (e.getMessage().contains(\"day-of-week AND a day-of-month\")) {\n        throw new IllegalArgumentException(\n            \"Quartz does not allow specifying both day-of-month and day-of-week. \" +\n            \"Use '?' for the field you want to ignore. Expression: \" + expression, e);\n    }\n    throw e;\n}","preventionTips":["Always use '?' (not '*') for the day field you want to ignore in Quartz cron.","If scheduling by day-of-month, set day-of-week to '?': '0 0 12 15 * ?'.","If scheduling by day-of-week, set day-of-month to '?': '0 0 12 ? * MON'.","Never use '*' for both day-of-month and day-of-week — use '?' for one of them.","Provide a cron expression builder in the UI that enforces the '?' exclusion rule."],"tags":["cron","quartz","scheduling","xxl-job","day-of-week","day-of-month"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}