Examples: LocalTime property (DateTime - Java™)
- This agent prints the creation date and time of the current database
in local time.
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(); String sLocalTime = createdDateTime.getLocalTime(); System.out.println ("Database \"" + db.getTitle() + "\" was created on " + sLocalTime + "."); } catch(Exception e) { e.printStackTrace(); } } }
- This agent sets the local date and time, then prints the date
and time in local time and GMT.
import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) DateTime dt = session.createDateTime("Today"); dt.setLocalTime("12/12/97 04:30:00 PM"); System.out.println(dt.getLocalTime()); System.out.println(dt.getGMTTime()); } catch(Exception e) { e.printStackTrace(); } } }
- This agent is the same as the preceding one but passes the date and time as
integer values to setLocalDate and setLocalTime, rather than as a
string to setLocalTime.
import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) DateTime dt = session.createDateTime("Today"); dt.setLocalDate(1997, 12, 12, true); dt.setLocalTime(1, 30, 0, 0); System.out.println(dt.getLocalTime()); System.out.println(dt.getGMTTime()); } catch(Exception e) { e.printStackTrace(); } } }