在Lotus Domino日历(版本8.5.1)中“全天”返回约会

时间:2017-02-28 16:54:37

标签: java lotus-notes lotus-domino

我计划在2017年2月23日至2017年3月3日期间在Lotus Domino日历(版本8.5.1)中“全天”预约。我使用NCSO.jar,我尝试以这种方式从Lotus Domino获得这个约会:

lotus.domino.Session s = null;
s = DominoSessionInfo.sessionInfo.getSession();
lotus.domino.Database maildb = getMailDb(sessionInfo);
lotus.domino.DateRange dr = s.createDateRange(startDate, endDate);
lotus.domino.View calview = maildb.getView("($Calendar)");
lotus.domino.ViewEntryCollection docColl = calview.getAllEntriesByKey(dr);

public static lotus.domino.Database getMailDb(DominoSessionInfo sessionInfo) throws NotesException, NamingException{

lotus.domino.Session s = DominoSessionInfo.sessionInfo.getSession();
log.info("Open DB on: " + s.getServerName() + " with mail server *" +
        sessionInfo.getProfileInfo().getMailServer() + "* and mail file *" +
        sessionInfo.getProfileInfo().getMailFile());
    lotus.domino.Database maildb = s.getDatabase(sessionInfo.getProfileInfo().getMailServer(),
        sessionInfo.getProfileInfo().getMailFile());
if (! maildb.isOpen()){
    maildb.open();
}
return maildb;
}

当dr.getText():02/27/2017 12:00:00 AM CET - 03/06/2017 12:00:00 AM CET(即startDate:02/27/2017 12:00:00 AM CET和endDate:03/06/2017 12:00:00 AM CET)当dr.getText():02/20/2017 12:00:00 AM CET - 02/27 /时,此代码不会返回此约会2017年中午12点00分(即开始日期:02/20/2017中午12点00分,结束日期:02/27/2017中午12点00分)此代码将返回此约会。

当startDate和endDate的值分别为02/27/2017 12:00:00 AM CET和03/06/2017 12:00:00 AM时,如何修改代码以便返回此约会CET

提前致谢。

图片:Appointment Lotus Notes screenshoot

1 个答案:

答案 0 :(得分:0)

最后我能够解决这个问题!而不是这段代码:

lotus.domino.DateRange dr = s.createDateRange(startDate, endDate);
lotus.domino.View calview = maildb.getView("($Calendar)");
lotus.domino.ViewEntryCollection docColl = calview.getAllEntriesByKey(dr);

我用过这个:

String strDateFormat;
// Get the date separator used on the Domino server, e.g. / or -
String dateSep = s.getInternational().getDateSep();
// Determine if the server date format is DMY, YMD, or MDY
if (s.getInternational().isDateDMY()) {
    strDateFormat = "dd" + dateSep + "MM" + dateSep + "yyyy";                
}
else if (s.getInternational().isDateYMD()) {
   strDateFormat = "yyyy" + dateSep + "MM" + dateSep + "dd";
}
else {
    strDateFormat = "MM" + dateSep + "dd" + dateSep + "yyyy";
}
DateFormat dateFormat = new SimpleDateFormat(strDateFormat);

String calendarQuery = "SELECT (@IsAvailable(CalendarDateTime) & @IsAvailable(EndDateTime) & (@Explode(CalendarDateTime) *<= @Explode(@TextToTime(\"" + dateFormat.format(endDate) + "\")))  (@Explode(EndDateTime) *>= @Explode(@TextToTime(\"" + dateFormat.format(startDate) + "\"))))";

lotus.domino.DocumentCollection queryResults = maildb.search(calendarQuery);

这样做我能够在任何时间间隔内返回约会“全天”(计划于2017年2月23日至2017年1月3日),该时间间隔至少包含计划预约的一天。 / p>

相关问题