TrackStudio Enterprise 3.5
Example 5

To get the time difference (in seconds) between two consecutive messages:

ArrayList messages = task.getMessages();
Collections.reverse(messages);

java.util.Date oldDate = task.getSubmitdate().getTime();
long diff = 0;

for(Iterator it = messages.iterator();it.hasNext();) {
   java.util.Date newDate = ((Calendar)it.next()).getTime();
   diff = newDate.getTime() - oldDate.getTime();
   oldDate = newDate;
}
return diff/1000;