jeecgboot/JeecgBoot · error · ParseException

Invalid Day-of-Week value: '{sub}'

Error message

Invalid Day-of-Week value: '{sub}'

What it means

In the DAY_OF_WEEK branch, the parser reads a 3-char alpha substring and calls getDayOfWeekNumber(sub). If it returns < 0 the token is not a recognized weekday abbreviation. Only SUN, MON, TUE, WED, THU, FRI, SAT are accepted. This guards the start token of a day-of-week expression.

Source

Thrown at jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java:568

                sval = getMonthNumber(sub) + 1;
                if (sval <= 0) {
                    throw new ParseException("Invalid Month value: '" + sub + "'", i);
                }
                if (s.length() > i + 3) {
                    c = s.charAt(i + 3);
                    if (c == '-') {
                        i += 4;
                        sub = s.substring(i, i + 3);
                        eval = getMonthNumber(sub) + 1;
                        if (eval <= 0) {
                            throw new ParseException("Invalid Month value: '" + sub + "'", i);
                        }
                    }
                }
            } else if (type == DAY_OF_WEEK) {
                sval = getDayOfWeekNumber(sub);
                if (sval < 0) {
                    throw new ParseException("Invalid Day-of-Week value: '"
                            + sub + "'", i);
                }
                if (s.length() > i + 3) {
                    c = s.charAt(i + 3);
                    if (c == '-') {
                        i += 4;
                        sub = s.substring(i, i + 3);
                        eval = getDayOfWeekNumber(sub);
                        if (eval < 0) {
                            throw new ParseException(
                                    "Invalid Day-of-Week value: '" + sub
                                            + "'", i);
                        }
                    } else if (c == '#') {
                        try {
                            i += 4;
                            nthDayOfWeek = Integer.parseInt(s.substring(i));
                            if (nthDayOfWeek < 1 || nthDayOfWeek > 5) {

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Use a valid 3-letter weekday code: SUN, MON, TUE, WED, THU, FRI, SAT.
  2. Prefer numeric day-of-week (1=SUN..7=SAT in this Quartz variant) to avoid abbreviation errors.
  3. Ensure the token is exactly 3 uppercase letters - the parser slices substring(i, i+3).
  4. For lists/ranges validate each element against the accepted set before submission.

Example fix

// before - misspelled weekday
String cron = "0 0 0 ? * MND";  // Invalid Day-of-Week value: 'MND'

// after - valid abbreviation or numeric
String cron = "0 0 0 ? * MON";
// or numeric (1=SUN..7=SAT)
String cron = "0 0 0 ? * 2";
Defensive patterns

Strategy: validation

Validate before calling

private static final java.util.Set<String> DOW =
    java.util.Set.of("SUN","MON","TUE","WED","THU","FRI","SAT");

// Validate a DAY_OF_WEEK field token before parsing.
public static String validateDowField(String field) {
    for (String part : field.split("[,#]")) {
        for (String end : part.split("-")) {
            String t = end.trim().toUpperCase().replaceAll("L$|W$", "");
            if (t.equals("*") || t.equals("?") || t.matches("\\d+") || t.matches("\\d+L")) continue;
            if (!DOW.contains(t)) return "invalid day-of-week token: " + end;
        }
    }
    return null;
}

Type guard

public static boolean isValidDowToken(String token) {
    String t = token == null ? "" : token.trim().toUpperCase();
    return "*".equals(t) || "?".equals(t) || "L".equals(t)
        || t.matches("[1-7]")
        || t.matches("[1-7]L")
        || DOW.contains(t);
}

Try / catch

try {
    new CronExpression(expr);
} catch (ParseException e) {
    if (e.getMessage().startsWith("Invalid Day-of-Week value")) {
        errors.rejectValue("dowField", "cron.dow.invalid",
            "Use SUN..SAT or 1..7 (1=SUN). Got: " + e.getMessage());
    } else throw e;
}

Prevention

When it happens

Trigger: Day-of-week field with an unknown alpha token, e.g. '0 0 0 ? * MND' (typo), '0 0 0 ? * MO' (truncated to 2 letters so the slice is bad), or '0 0 0 ? * Monday' (full name, slice 'Mon' may pass getDayOfWeekNumber only if case-insensitive - but here the branch requires uppercase A-Z and the lookup is case-folded; a stray non-matching slice still fails).

Common situations: Misspelled weekday abbreviations; using full day names; truncation when the dow field is built from a substring; locale assumptions about day names.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/65e02e047e6c693c. Report an issue: GitHub.