{"record":{"id":"be1d6f1ed7de4aeb","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-string-to-localdatetime","errorCode":null,"errorMessage":"Converter can only convert string to localDateTime","messagePattern":"Converter can only convert string to localDateTime","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LocalDateTimeRestVariableConverter.java","lineNumber":39,"sourceCode":" * @author Filip Hrisafov\n */\npublic class LocalDateTimeRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"localDateTime\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return LocalDateTime.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            if (!(result.getValue() instanceof String)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert string to localDateTime\");\n            }\n            try {\n                return LocalDateTime.parse((String) result.getValue());\n            } catch (DateTimeParseException e) {\n                throw new FlowableIllegalArgumentException(\"The given variable value is not a localDateTime: '\" + result.getValue() + \"'\", e);\n            }\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof LocalDateTime)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert localDateTime\");\n            }\n            result.setValue(variableValue.toString());\n        } else {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LocalDateTimeRestVariableConverter.java#L21-L57","documentation":"LocalDateTimeRestVariableConverter.getVariableValue deserializes a REST variable into a java.time.LocalDateTime and requires the REST value to be a String. A non-String value fails the instanceof guard and throws FlowableIllegalArgumentException, because only strings can be passed to LocalDateTime.parse.","triggerScenarios":"Sending a localDateTime REST variable whose JSON value is a number (epoch), array (Jackson date-as-array), object, or boolean instead of an ISO-8601 datetime string, so result.getValue() is not a String.","commonSituations":"Clients serializing datetimes as epoch millis or [yyyy,MM,dd,...] arrays; typed HTTP clients deserializing into OffsetDateTime/Instant before the converter runs; timezone-aware payloads sent to a timezone-less variable type.","solutions":["Send the value as an ISO-8601 local datetime string (yyyy-MM-dd'T'HH:mm:ss), e.g. \"2026-09-10T14:30:00\".","Ensure the client's JSON serializer emits dates as ISO strings, not timestamps or arrays.","Convert epoch millis/Instant values to LocalDateTime strings client-side.","If the payload carries an offset/zone, either strip it or use a variable type that supports it."],"exampleFix":"// before\n{ \"type\": \"localDateTime\", \"value\": [2026, 9, 10, 14, 30] }\n\n// after\n{ \"type\": \"localDateTime\", \"value\": \"2026-09-10T14:30:00\" }","handlingStrategy":"validation","validationCode":"if (!(rawValue instanceof String s)) {\n    throw new IllegalArgumentException(\"localDateTime variable must be a JSON string, got: \"\n        + (rawValue == null ? \"null\" : rawValue.getClass().getSimpleName()));\n}\nLocalDateTime.parse(s); // fail fast on format","typeGuard":"static boolean isIsoLocalDateTimeString(Object v) {\n    return v instanceof String s && s.matches(\"\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}(:\\\\d{2}(\\\\.\\\\d+)?)?\");\n}","tryCatchPattern":"try {\n    Object value = converter.getVariableValue(restVar);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid localDateTime variable: {}\", restVar.getValue(), e);\n}","preventionTips":["Send datetimes as ISO-8601 strings like 2026-09-10T14:30:00.","Configure client mappers with WRITE_DATES_AS_TIMESTAMPS disabled.","Strip zone/offset info or use a zoned type if the payload is zone-aware."],"tags":["localdatetime","rest-variable","type-mismatch","date"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}