Examples: timeDifference method

This agent calculates the number of days since a document was created.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      DateTime createdDateTime = db.getCreated();
      DateTime nowDateTime = session.createDateTime("Today");
      nowDateTime.setNow();
      int daysSinceCreated =
      nowDateTime.timeDifference(createdDateTime) / 86400;
      System.out.println
      ("Database \"" + db.getTitle() +
      "\" was created " + daysSinceCreated + " days ago.");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}