Examples: openDatabaseIfModified method

This agent opens name.nsf in the local directory if the database was modified in the past three hours.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      DbDirectory dir = session.getDbDirectory(null);
      DateTime dt = session.createDateTime("Today");
      dt.setNow();
      dt.adjustHour(-3);
      Database db = dir.openDatabaseIfModified("names", dt);
      if (db != null)
        System.out.println("Database opened");
      else
        System.out.println(
           "Database not modified in past 3 hours");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}