Domino Code Fragment

Code Name*
SetNow method
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.143.23.176
Description*
This agent increments the current time by 2 months and appends this value to the PurgeDate item.
Type*
Java
Categories*
Date/Time Handling
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
import lotus.notes.*;


public class setnowagent extends AgentBase
{
 public void NotesMain()
 {
   try
   {
     Session s = getSession();
     AgentContext ac = s.getAgentContext();
     Database db = ac.getCurrentDatabase();
     Document doc = db.createDocument();
     DateTime dt = s.createDateTime("");
     dt.setNow();
     System.out.println(dt.getLocalTime());
     dt.adjustMonth(2, true);
     System.out.println(dt.getLocalTime());
     doc.appendItemValue("Subject", "2-month document");
     System.out.println("value appended to Subject");
     doc.appendItemValue("PurgeDate", dt);
     System.out.println("value appended to PurgeDate");
     doc.save(true, true);
   }
   catch (Exception e)
   {
     e.printStackTrace();
   }
 }
}