Get taskEndTime from historicTaskInstance with timestap

Hi,

i want to get the task endTime from historicTaskInstance with timestamp but historicTaskInstance.getEndTime() → return ‘Date’ without timestamp.

Could anybody help me out?

Thanks in Advance,
Adithyan

Hello @Adithyan,
It is correct that a Date object is returned as it is specified in the Java-API. Nevertheless, this Date object contains all the information you need:

    //assumimng you already have an historyService
	HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().list().get(0);
    Date endTime = historicTaskInstance.getEndTime();
    System.out.println("End Time: " + endTime);

    Calendar cal = new GregorianCalendar();
    cal.setTime(endTime);
    System.out.println("Converted Calender Time: " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE ) + ":" + cal.get(cal.SECOND));

===> outputs:

    End Time: Fri Aug 16 16:00:42 CEST 2019
    Converted Calender Time: 16:0:42

Hope that helps!

Best, Stefan