TrackStudio Enterprise 3.1
Example 7

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

 int ret = 0;

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

 java.sql.Timestamp oldDate =
      task.getSubmitdate();
 long diff = 0;

 for(Iterator it = messages.iterator();
     it.hasNext();) {

    java.sql.Timestamp newDate =
       it.next().getTime();
    diff = newDate.getTime() - oldDate.getTime();
    oldDate = newDate;

 }
 return diff/1000;
Copyright (c) 2002-2005. All rights reserved.