//create a new Date
Date firstDateOfYear = Date.from(LocalDate.now().with(firstDayOfYear()).atStartOfDay().atZone(ZoneId.systemDefault());
//create Query instance
HistoricProcessInstanceQueryDto historicProcessInstanceQuery = new HistoricProcessInstanceQueryDto();
//startedAfter only takes Date format, due to legacy setting as in original post.
historicProcessInstanceQuery.startedAfter(firstDateOfYear);
//fails due to wrong date format
historicProcessInstanceApi.queryHistoricProcessInstancesCount(historicProcessInstanceQuery);