{"record":{"id":"e1d90ad88752ce72","repo":"flowable/flowable-engine","slug":"date-object-cannot-be-empty","errorCode":null,"errorMessage":"date object cannot be empty","messagePattern":"date object cannot be empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DateUtil.java","lineNumber":30,"sourceCode":" */\npackage org.flowable.dmn.engine.impl.el.util;\n\nimport java.time.ZoneId;\nimport java.util.Date;\n\nimport org.flowable.common.engine.impl.joda.JodaDeprecationLogger;\nimport org.joda.time.LocalDate;\nimport org.joda.time.format.DateTimeFormat;\nimport org.joda.time.format.DateTimeFormatter;\n\n/**\n * @author Yvo Swillens\n */\npublic class DateUtil {\n\n    public static Date toDate(Object dateObject) {\n        if (dateObject == null) {\n            throw new IllegalArgumentException(\"date object cannot be empty\");\n        }\n\n        if (dateObject instanceof Date) {\n            return (Date) dateObject;\n        } else if (dateObject instanceof LocalDate) {\n            JodaDeprecationLogger.LOGGER.warn(\"Using Joda-Time LocalDate has been deprecated and will be removed in a future version.\");\n            return ((LocalDate) dateObject).toDate();\n        } else if (dateObject instanceof java.time.LocalDate) {\n            return Date.from(((java.time.LocalDate) dateObject).atStartOfDay()\n                    .atZone(ZoneId.systemDefault())\n                    .toInstant());\n        } else {\n            DateTimeFormatter dtf = DateTimeFormat.forPattern(\"yyyy-MM-dd\");\n            LocalDate dateTime = dtf.parseLocalDate((String) dateObject);\n            return dateTime.toDate();\n        }\n    }\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DateUtil.java#L12-L48","documentation":"DateUtil.toDate converts DMN expression operands (Date, LocalDate, String, etc.) into java.util.Date. It throws IllegalArgumentException('date object cannot be empty') when the operand is null, because the engine cannot convert a missing value into a date for comparison in date-based DMN expressions.","triggerScenarios":"A DMN expression (e.g. before(date, x) / after(date, x) / date comparison in a decision table) receives null as its date operand, either as a literal null or from an unbound variable.","commonSituations":"Date input variables not set in the process/form; spelling mismatch between the variable name in the expression and the incoming data; test data missing a date field that production data has; deprecated Joda-Time LocalDate usage paths receiving null.","solutions":["Populate the date variable before decision-table evaluation (set it in the process or form data)","Add a null check/default in the DMN expression, e.g. a ternary returning a default date","Verify the input variable name in the decision table matches the supplied data key","Validate input data before starting the process instance that evaluates the decision"],"exampleFix":"// before (unbound variable passed as date)\nafter(creationDate, '2024-01-01')\n// after\ncreationDate != null ? after(creationDate, '2024-01-01') : false","handlingStrategy":"validation","validationCode":"if (dateValue == null) throw new IllegalArgumentException(\"date variable must be set before decision evaluation\");","typeGuard":"boolean isDateLike(Object o) { return o instanceof java.util.Date || o instanceof org.joda.time.LocalDate || o instanceof java.time.temporal.TemporalAccessor || o instanceof String; }","tryCatchPattern":"try { Date d = DateUtil.toDate(obj); } catch (IllegalArgumentException e) { d = defaultDate; }","preventionTips":["Ensure date variables are set in process/form data before the decision table runs","Match variable names between expression and data source exactly","Validate required date fields at data entry time"],"tags":["dmn","date","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}