Date form field default value

I am facing problem with default values for date fields in generated task forms.

In the start form I specify a date value.

<bpmn:startEvent id="StartEvent_1">
  <bpmn:extensionElements>
    <camunda:formData>
      <camunda:formField id="goal_date" label="Goal Date" type="date" datePattern="yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" />
    </camunda:formData>
  </bpmn:extensionElements>
</bpmn:startEvent>

It seems to me, that the variable is getting stored correctly as a date value in the database when the process gets instantiated .

select var.name_, var.type_, var.long_ 
from act_ru_variable var 
where name_ = 'goal_date';
name_ type_ long_
goal_date date 1529445600000

A subsequent task form is specified with goal_date as default:

<bpmn:userTask id="approval" name="Approval" camunda:assignee="${requester}">
  <bpmn:extensionElements>
    <camunda:formData>
      <camunda:formField id="new_goal_date" label="New Goal Date" type="date" defaultValue="${goal_date}" datePattern="yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" />
    </camunda:formData>
  </bpmn:extensionElements>
</bpmn:userTask>

If I try to retrive the form data like so:

this.formService.getTaskFormData(taskId);

I am getting this error:

Caught org.camunda.bpm.engine.ProcessEngineException: invalid date value Wed Jun 20 00:00:00 CEST 2018, treating it as an 500 (INTERNAL_SERVER_ERROR) response
org.camunda.bpm.engine.ProcessEngineException: invalid date value Wed Jun 20 00:00:00 CEST 2018
	at org.camunda.bpm.engine.impl.form.type.DateFormType.convertFormValueToModelValue(DateFormType.java:97)
	at org.camunda.bpm.engine.impl.form.handler.FormFieldHandler.createFormField(FormFieldHandler.java:74)
	at org.camunda.bpm.engine.impl.form.handler.DefaultFormHandler.initializeFormFields(DefaultFormHandler.java:276)
	at org.camunda.bpm.engine.impl.form.handler.DefaultTaskFormHandler.createTaskForm(DefaultTaskFormHandler.java:42)
	at org.camunda.bpm.engine.impl.form.handler.CreateTaskFormInvocation.invoke(CreateTaskFormInvocation.java:34)
	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)
	at org.camunda.bpm.engine.impl.form.handler.DelegateTaskFormHandler$1.call(DelegateTaskFormHandler.java:36)
	at org.camunda.bpm.engine.impl.form.handler.DelegateTaskFormHandler$1.call(DelegateTaskFormHandler.java:33)
	at org.camunda.bpm.engine.impl.form.handler.DelegateFormHandler.doCall(DelegateFormHandler.java:66)
	at org.camunda.bpm.engine.impl.form.handler.DelegateFormHandler.performContextSwitch(DelegateFormHandler.java:60)
	at org.camunda.bpm.engine.impl.form.handler.DelegateTaskFormHandler.createTaskForm(DelegateTaskFormHandler.java:33)
	at org.camunda.bpm.engine.impl.cmd.GetTaskFormCmd.execute(GetTaskFormCmd.java:54)
	at org.camunda.bpm.engine.impl.cmd.GetTaskFormCmd.execute(GetTaskFormCmd.java:32)
	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.camunda.bpm.engine.impl.FormServiceImpl.getTaskFormData(FormServiceImpl.java:64)

I don’t know if this is related to the datePattern setting. I was trying to omit the datePattern attribute on the user task but it results the same error.

Hi @f_a,

Which camunda version do you use?

Best regards,
Yana

Hello @yana.vasileva,

at the moment we still use 7.8 but I just downloaded the latest 7.9 version to check and it gives the same error.

Here is an example to reproduce the problem:

datedefault.bpmn (3.1 KB)

Hi @f_a,

Thank you very much for the example.
It is failing because the value is treated as a string.
DateFormType.java#convertFormValueToModelValue()
Feel free to open a bug report or raise a pull request.

As workaround you can try to convert the date to a string in another variable and use the second string variable later in the user task.

Best regards,
Yana

Facing the same issue. Submitted a bug report: https://app.camunda.com/jira/browse/CAM-10211