{"record":{"id":"60d4397bb43aad1d","repo":"jeecgboot/JeecgBoot","slug":"day-of-week-values-must-be-between-1-and-7","errorCode":null,"errorMessage":"Day-of-Week values must be between 1 and 7","messagePattern":"Day-of-Week values must be between 1 and 7","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":756,"sourceCode":"    }\n\n    protected int checkNext(int pos, String s, int val, int type)\n            throws ParseException {\n\n        int end = -1;\n        int i = pos;\n\n        if (i >= s.length()) {\n            addToSet(val, end, -1, type);\n            return i;\n        }\n\n        char c = s.charAt(pos);\n\n        if (c == 'L') {\n            if (type == DAY_OF_WEEK) {\n                if(val < 1 || val > 7)\n                    throw new ParseException(\"Day-of-Week values must be between 1 and 7\", -1);\n                lastDayOfWeek = true;\n            } else {\n                throw new ParseException(\"'L' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            TreeSet<Integer> set = getSet(type);\n            set.add(val);\n            i++;\n            return i;\n        }\n\n        if (c == 'W') {\n            if (type != DAY_OF_MONTH) {\n                throw new ParseException(\"'W' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            if(val > 31)\n                throw new ParseException(\"The 'W' option does not make sense with values larger than 31 (max number of days in a month)\", i);\n            nearestWeekdays.add(val);\n            i++;","sourceCodeStart":738,"sourceCodeEnd":774,"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#L738-L774","documentation":"Thrown by CronExpression's token parser when the 'L' (last) modifier is used in the day-of-week field but the preceding numeric value falls outside the valid range of 1–7. In this implementation SUN=1 through SAT=7, so values like 0L or 8L are rejected before the lastDayOfWeek flag is set. The check fires inside the character-by-character field parser after an 'L' is detected at the current position.","triggerScenarios":"A cron expression containing a day-of-week token of the form <number>L where <number> is less than 1 or greater than 7 — e.g. the DOW field '0L', '8L', or '-1L'. The parser has already consumed the numeric part into `val` and then sees 'L' as the next character with type==DAY_OF_WEEK.","commonSituations":"Developer assumes 0-based weekdays (0=Sunday) and writes '0 0 0 ? * 0L'; developer copies a cron from a system that uses 0–6 weekday numbering; off-by-one when translating from ISO 8601 (Monday=1..Sunday=7) to this library's Sunday=1 convention.","solutions":["Change the day-of-week number in the 'L' token to a value between 1 and 7 (1=Sunday … 7=Saturday in this library).","If you meant 'last day of the week' generically, use '7L' (last Saturday) or the specific weekday you intend.","Double-check against Quartz cron documentation: 1=SUN, 2=MON, 3=TUE, 4=WED, 5=THU, 6=FRI, 7=SAT."],"exampleFix":"// before\nString cron = \"0 0 0 ? * 0L\";  // 0 is invalid\n// after\nString cron = \"0 0 0 ? * 1L\";  // last Sunday of the month","handlingStrategy":"validation","validationCode":"// Validate DOW 'L' value before constructing CronExpression\nint dowVal = /* the number before 'L' */;\nif (dowVal < 1 || dowVal > 7) {\n    throw new IllegalArgumentException(\"Day-of-Week 'L' value must be 1-7, got: \" + dowVal);\n}","typeGuard":"boolean isValidDowLToken(String token) {\n    if (!token.endsWith(\"L\")) return true;\n    try {\n        int val = Integer.parseInt(token.substring(0, token.length() - 1));\n        return val >= 1 && val <= 7;\n    } catch (NumberFormatException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expr);\n} catch (ParseException e) {\n    if (e.getMessage().contains(\"Day-of-Week values must be between 1 and 7\")) {\n        // guide user to fix the 'L' weekday token\n    }\n    throw e;\n}","preventionTips":["Always use 1=Sunday through 7=Saturday for day-of-week values in this library.","Pre-validate cron strings with a utility method before passing to CronExpression.","When building cron strings dynamically, bounds-check each field value against its valid range."],"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"}