flowable/flowable-engine · error · FlowableIllegalArgumentException
Converter can only convert string to date
Error message
Converter can only convert string to date
What it means
DateRestVariableConverter expects the REST variable's value to be a String containing a date in the long/timestamp format parsed by RequestUtil.parseLongDate. If the value is not a String, the converter cannot even attempt parsing, so FlowableIllegalArgumentException 'Converter can only convert string to date' is thrown before parsing.
Source
Thrown at modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/DateRestVariableConverter.java:41
* @author Frederik Heremans
*/
public class DateRestVariableConverter implements RestVariableConverter {
@Override
public String getRestTypeName() {
return "date";
}
@Override
public Class<?> getVariableType() {
return Date.class;
}
@Override
public Object getVariableValue(EngineRestVariable result) {
if (result.getValue() != null) {
if (!(result.getValue() instanceof String)) {
throw new FlowableIllegalArgumentException("Converter can only convert string to date");
}
try {
return RequestUtil.parseLongDate((String) result.getValue());
} catch (DateTimeParseException e) {
throw new FlowableIllegalArgumentException("The given variable value is not a date: '" + result.getValue() + "'", e);
}
}
return null;
}
@Override
public void convertVariableValue(Object variableValue, EngineRestVariable result) {
if (variableValue != null) {
if (!(variableValue instanceof Date dateValue)) {
throw new FlowableIllegalArgumentException("Converter can only convert booleans");
}
result.setValue(dateValue.toInstant().toString());
} else {View on GitHub (pinned to d6d39ce1c6)
Solutions
- Send date variable values as strings, e.g. "1694044800000" (long millis as string), matching the converter's expected format.
- Check the REST variable 'type' so numeric values are handled by the appropriate converter rather than the date one.
- If you build EngineRestVariable yourself, set value to a String: String.valueOf(timestamp).
- For other date formats, convert client-side to epoch millis string before sending (parseLongDate accepts epoch millis).
Example fix
// before restVariable.setValue(1694044800000L); // Long -> throws // after restVariable.setValue(String.valueOf(1694044800000L)); // epoch millis as string
Defensive patterns
Strategy: type-guard
Validate before calling
if (value != null && !(value instanceof String)) {
value = String.valueOf(value); // epoch millis number -> string
} Type guard
String asDateString(Object v) {
if (v instanceof String) return (String) v;
if (v instanceof Number) return String.valueOf(v.longValue());
return null;
} Try / catch
try {
Object v = converter.getVariableValue(restVariable);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("convert string to date")) {
throw new IllegalArgumentException("Date variables must be epoch-millis strings, got: " + restVariable.getValue(), e);
}
throw e;
} Prevention
- Send date variables as epoch-millis strings, not JSON numbers or Date objects.
- Confirm the variable 'type' maps to the date converter only for string values.
- Coerce numeric timestamps to strings before populating EngineRestVariable.
- Share a client-side date serialization helper so all date variables use one valid format.
When it happens
Trigger: getVariableValue invoked on an EngineRestVariable whose value is a non-String (e.g. a Number/Long object or JSON number deserialized as Integer) while this date converter was selected for the variable.
Common situations: Clients sending epoch-millis as a JSON number instead of a string for date variables; type mapping selecting the date converter for non-string payloads; custom code stuffing pre-parsed Date objects into EngineRestVariable.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Variable '${restVariable.getName()}' has unsupported type: '
- Converter can only convert big decimal values
- Converter can only convert big integer values
- Converter can only convert booleans
- Converter can only convert booleans
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9fef0e70d3b4f869.
Report an issue: GitHub.