Change Dateformat of DTOs

Hello everyone,

I am building a custom REST API. My goal is to consolidate REST API calls like GET /process-instance/ and GET /tasks into one call.
In order to achieve that, I query for all processInstances and their tasks. For each Task the following code stores the parameters into a jsonArray by using the TaskDto method fromExecution().

JsonArray jsonArrayTask = new JsonArray();
List<Task> taskList = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).list();
taskList.forEach((task) -> jsonArrayTask.add(gson.toJsonTree(TaskDto.fromEntity(task))));

Problem is:
The date parameters like created or due have the following format: “MMM dd, YYY, hh:mm:ss a”.
My desired format is the XML Date format, like in the native REST API calls.

Can you recommend a good way to change the default date format of the DTOs without changing every DTO itself?