org.camunda.bpm.dmn.engine.DmnEngineException: Unsupported type: 'java.time.LocalDate' cannot be converted to 'java.util.Date'

Hello,

I’m using:
Camunda Version 7.14.0
Spring Boot 2.3.6.RELEASE
Java 11

In my BPM process I have a custom variable instantiated

    @Data
    public class Contract implements java.io.Serializable {
        private String productCode;
        private String refinanceOrigin;
        private LocalDate startDefaultDate;
    }

with an attribute of type LocalDate (startDefaultDate) that I will later use in a Table Decision invoked from a Business Rule Task

When the rules are executed the following error is thrown:

19:46:12.637 [main] INFO  org.camunda.feel.FeelEngine - Engine created. [value-mapper: CompositeValueMapper(List(org.camunda.feel.impl.JavaValueMapper@4bd1f8dd)), function-provider: org.camunda.bpm.dmn.feel.impl.scala.function.CustomFunctionTransformer@7096b474, clock: SystemClock, configuration: Configuration(false)]

org.camunda.bpm.dmn.engine.DmnEngineException: Unsupported type: 'java.time.LocalDate' cannot be converted to 'java.util.Date'

	at org.camunda.bpm.dmn.engine.impl.type.DateDataTypeTransformer.unsupportedType(DateDataTypeTransformer.java:105)
	at org.camunda.bpm.dmn.engine.impl.type.DateDataTypeTransformer.transform(DateDataTypeTransformer.java:76)
	at org.camunda.bpm.dmn.engine.impl.type.DmnTypeDefinitionImpl.transformNotNullValue(DmnTypeDefinitionImpl.java:54)
	at org.camunda.bpm.dmn.engine.impl.type.DmnTypeDefinitionImpl.transform(DmnTypeDefinitionImpl.java:45)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInput(DecisionTableEvaluationHandler.java:123)

I created a new transformer:

public class LocalDateDataTypeTransformer extends DateDataTypeTransformer {

    protected SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

    protected Date transformString(String value) {
        try {
            return format.parse(value);
        }
        catch (ParseException e) {
            throw new IllegalArgumentException(e);
        }
}
}

But I dont understand how to register it in SpringBoot BMP Engine.
How would it be done from a configuration class (@Configuration)? Is this the way?
Thanks in advance
Caro.

Today I continue with some testing…

When I replace my LocalDate type by Date type, this error is thrown:

org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression '> today()': ValLocalDateTime(2021-04-08T00:00) can not be compared to ValDate(2021-04-08)

	at org.camunda.bpm.dmn.feel.impl.scala.ScalaFeelLogger.evaluationException(ScalaFeelLogger.java:77)
	at org.camunda.bpm.dmn.feel.impl.scala.ScalaFeelEngine.evaluateSimpleUnaryTests(ScalaFeelEngine.java:115)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateFeelSimpleUnaryTests(DecisionTableEvaluationHandler.java:246)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputEntry(DecisionTableEvaluationHandler.java:203)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.isConditionApplicable(DecisionTableEvaluationHandler.java:145)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputForAvailableRules(DecisionTableEvaluationHandler.java:137)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateDecisionTable(DecisionTableEvaluationHandler.java:111)
	at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluate(DecisionTableEvaluationHandler.java:81)
	at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateDecision(DefaultDmnDecisionContext.java:85)

So … to use the expression today () what is the data type to use in the variable?

up. Any idea?

Hi @Carolina_Barbiero :wave:

DMN/FEEL supports different date-time values. For example,

  • date (i.e. LocalDate)
  • time with/without timezone
  • date-time with/without timezone

The easiest way to deal with date variables (i.e. LocalDate) is to store them as ISO 8601 string. In the DMN decision, you can use the function date() to transform the string into a date value.

Note that the type date in the decision input column references to java.util.Date. In FEEL, a java.util.Date is transformed to a date-time value without timezone.

Read more about comparing a date-time value in the related thread: How to compare date with current date and time in DMN? - #4 by Philipp_Ossler?

Does this help you?

Best regards,
Philipp