Hi!
I have a listener attached to the “create” event of the tasks to do some logic. I need to assign the due date to one of the variables created during the process start.
I can get the variable value using this code:
public void notify(DelegateTask delegateTask) {
DelegateExecution ex = delegateTask.getExecution();
String due_date = ex.getVariable("due_date").toString();
The problem is that I get a string like Sat Feb 13 00:00:00 CET 2021
and the setDueDate
method of the delegate task expects a Date
, so I have to convert it:
DateFormat formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss z yyyy");
Date parsedDate = (Date)formatter.parse(fecha_vencimiento);
delegateTask.setDueDate(parsedDate);
Is there a way to obtain the variable value as a Date
object instead of a parsed string?
Thanks!