Working with time

The DateTime class represents a date-time. Use createDateTime in Session to create a DateTime object. Various methods throughout the lotus.domino package return DateTime objects.

The following methods access the DateTime properties:

  • getLocalTime returns a String value containing a date-time in local time; setLocalTime with a String parameter sets the date-time to the local time represented by the String; setLocalTime with int parameters sets the time component of the date-time; setLocalDate, which takes int parameters, sets the date component of the date-time.
  • getGMTTime returns a String value containing a date-time in GMT.
  • getDateOnly returns a String value containing the date component of a date-time in local time.
  • getTimeOnly returns a String value containing the date component of a date-time in local time.
  • getTimeZone returns an int value containing the time zone of a date-time; setTimeZone sets the time zone.
  • getZoneTime returns a String value containing a date-time adjusted for the time zone and daylight-saving time, which can be changed with convertToZone.
  • isDST returns true if a date-time is in daylight-saving time.
  • getParent returns a Session object representing the current session.

You can change a date-time with the following methods: adjustSecond, adjustMinute, adjustHour, adjustDay, adjustMonth, and adjustYear. You can initialize a date-time or date-time component with the following methods: setNow, setAnyDate, and setAnyTime. You can get the difference in seconds between two times with timeDifference. You can convert a date-time to a java.util.Date object with toJavaDate.

The DateRange class represents a range of dates. The following methods access the DateTime properties:

  • getEndDateTime returns a DateTime object representing the end date of the range; setEndDateTime sets the end date of the range to the specification of a DateTime object.
  • getStartDateTime returns a DateTime object representing the start date of the range; setStartDateTime sets the start date of the range to the specification of a DateTime object.
  • getText returns a String value containing the range (two date-times in String format separated by a hyphen); setText sets the range to the specification of a String value.
  • getParent returns a Session object representing the current session.

When you set a DateRange object, write to either StartDate and EndDate, or Text, but not both. Values written to StartDate or EndDate are immediately transcribed to Text, and vice-versa. Any changes made to the DateTime object that is the basis for StartDateTime or EndDateTime also affect the DateRange object.