How to manipulate dates in Flowable open source?

Hello everyone,

I read in this forum that the expression ${date:now()} should provide the current date.
However, when I try to use it, I get
{
“message”: “Internal server error”,
“exception”: “Error parsing XML”
}
i.e., it is not recognized by my engine (I have the Flowable Orchestrate version and I am certain that my setup is correct)

How can I get the today date in the open source version then ?
And more generally, what are the primitive methods used to manipulate dates for Unified expression language used between ${""} ? I looked up online with no success (what I mean by manipulating is for example subtracting or adding two dates together, etc).

Best regards

HI!

I guess you will have to provide information on in what type of construct you are using this juel-expression. That date:now() function you are referring to seems to be implmented in the dmn-engine and can be used in decision table expressions.

What are you trying to accomplish? You could probably use a script task and do all the date manipulation you want using groovy for example.

/Erik

1 Like

Hello, thank you a lot for your answers !
Actually I am trying to accomplish three things.

  1. I have to extract the month of the current date and test a condition on it (I have to test if it is a certain month, let’s say May for instance)
  2. I have to subtract an input date to the current day of today to see if the difference between these two dates is superior to 10 days.
  3. I have to subtract an input date to the current day of today to see if the difference between these two dates is superior or equal to 4 weeks.

I do not know how to subtract and manipulate the dates, nor to begin by extracting the current date :slight_smile:
The remaining part, namely test the conditions, I totally know how to do it. I am just stuck about how to retrieve the dates and manipulate them.

Best regards

Well I would do it in a script-task and use groovy as the language. That way you could do it in java. (which I prefer). Do manipulations you need and then set process variables by calling execution.setVariable(“moreThan10Days”, true); for example. Then make a juel-expression where you need it for example as a condition on a gateway to choose which path to go in the process.

I’ll post some ideas here…


1 Like

Yes LocalDate can be used to get system date. Flowable uses org.flowable.common.engine.impl.runtime.ClockReader to get current time. Flowable Clock implementation is used to manage time in flowable, especially during simulations. (To get clock use
CommandContextUtil.getProcessEngineConfiguration().getClock().
From my point of view DMN ${date:now()} should also use ClockReader instead of localTime.

BusinessCalendar is used to resolve due dates for timers.

Regards
Martin

1 Like

Hello, sorry to dig up this thread, so I read your screenshot script for inspiration. I put “javascript” as a script language, but my engine does not recognize the first line “import java.time.*”, the problem being: “exception": "problem evaluating script: <eval>:1:0 Expected an operand but found import\nimport java.time.*\n^ in <eval> at line number 1 at column number 0”.

Thank you a lot in advance

Which JDK are you running this on (as the JDK defines the javascript engine)?