{"record":{"id":"7eaf9a139d6c4fb0","repo":"jeecgboot/JeecgBoot","slug":"day-of-month-values-must-be-between-1-and-31","errorCode":null,"errorMessage":"Day of month values must be between 1 and 31","messagePattern":"Day of month values must be between 1 and 31","errorType":"validation","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":1000,"sourceCode":"            throws ParseException {\n\n        TreeSet<Integer> set = getSet(type);\n\n        if (type == SECOND || type == MINUTE) {\n            if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {\n                throw new ParseException(\n                        \"Minute and Second values must be between 0 and 59\",\n                        -1);\n            }\n        } else if (type == HOUR) {\n            if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {\n                throw new ParseException(\n                        \"Hour values must be between 0 and 23\", -1);\n            }\n        } else if (type == DAY_OF_MONTH) {\n            if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)\n                    && (val != NO_SPEC_INT)) {\n                throw new ParseException(\n                        \"Day of month values must be between 1 and 31\", -1);\n            }\n        } else if (type == MONTH) {\n            if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) {\n                throw new ParseException(\n                        \"Month values must be between 1 and 12\", -1);\n            }\n        } else if (type == DAY_OF_WEEK) {\n            if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT)\n                    && (val != NO_SPEC_INT)) {\n                throw new ParseException(\n                        \"Day-of-Week values must be between 1 and 7\", -1);\n            }\n        }\n\n        if ((incr == 0 || incr == -1) && val != ALL_SPEC_INT) {\n            if (val != -1) {\n                set.add(val);","sourceCodeStart":982,"sourceCodeEnd":1018,"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#L982-L1018","documentation":"Thrown by addToSet when a value (or range end) for the DAY_OF_MONTH field is less than 1 or greater than 31, unless the value is ALL_SPEC_INT ('*') or NO_SPEC_INT ('?'). Valid day-of-month values are 1–31.","triggerScenarios":"A cron expression with a day-of-month field containing a value like 0, 32, or -1 — e.g., day-of-month field '32', '0', or range '1-35'.","commonSituations":"Developer uses 0 as a day (days start at 1); uses 32 or higher; range endpoint exceeds 31; confusion with 0-based indexing from other systems.","solutions":["Ensure all day-of-month values are integers from 1 to 31.","Use '?' in the day-of-month field if you are specifying day-of-week instead.","Note that while 29–31 are syntactically valid, they will skip months that have fewer days."],"exampleFix":"// before\nString cron = \"0 0 0 0 * ?\";  // 0 is invalid for day-of-month\n// after\nString cron = \"0 0 0 1 * ?\";  // 1st of month","handlingStrategy":"validation","validationCode":"// Validate day-of-month field values are 1-31\nString domField = fields[3];\nfor (String token : domField.split(\",\")) {\n    if (token.equals(\"*\") || token.equals(\"?\")) continue;\n    String base = token.replaceAll(\"[LW#].*\", \"\").split(\"[/\\\\-]\")[0];\n    if (!base.isEmpty()) {\n        int val = Integer.parseInt(base);\n        if (val < 1 || val > 31) throw new IllegalArgumentException(\"Day-of-month must be 1-31: \" + val);\n    }\n}","typeGuard":"boolean isValidDayOfMonth(String field) {\n    for (String token : field.split(\",\")) {\n        if (token.equals(\"*\") || token.equals(\"?\")) continue;\n        String base = token.replaceAll(\"[LW#].*\", \"\").split(\"[/\\\\-]\")[0];\n        try {\n            int val = Integer.parseInt(base);\n            if (val < 1 || val > 31) return false;\n        } catch (NumberFormatException e) { return false; }\n    }\n    return true;\n}","tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expr);\n} catch (ParseException e) {\n    if (e.getMessage().contains(\"Day of month values must be between 1 and 31\")) {\n        // fix the day-of-month field value\n    }\n    throw e;\n}","preventionTips":["Day-of-month values start at 1, not 0.","Values 29–31 are syntactically valid but will be skipped in shorter months.","Use '?' for day-of-month when scheduling by day-of-week."],"tags":["cron","validation","scheduling","xxljob","parse"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}