Domino Code Fragment
Code Name* TimeDifference method | Date* 04/29/2024 | Source (or email address if you prefer)* Rlatulippe@romac.com IP address:.3.129.67.26 | |
Description* This agent calculates the number of days since a document was created. | Type* Java | Categories* (Misc) |
Implementation: | Required Client: | Server: |
Limitations: | Comments: |
public class timedifferenceagent extends AgentBase
{
public void NotesMain()
{
try
{
Session s = getSession();
AgentContext ac = s.getAgentContext();
Database db = ac.getCurrentDatabase();
DateTime createdDateTime = db.getCreated();
DateTime nowDateTime = s.createDateTime("");
nowDateTime.setNow();
int daysSinceCreated =
nowDateTime.timeDifference(createdDateTime) / 86400;
System.out.println
("Database \"" + db.getTitle() +
"\" was created " + daysSinceCreated + " days ago.");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}