我有查询Lotus Notes Domino服务器(基于开始和结束日期范围)的日历条目的Java代码。以下是代码的简化版本。查询独立于日期区域设置的Lotus Domino日历条目
查询Domino服务器格式化日期与本地客户端相同时,一切正常,例如,服务器和客户端都使用m/d/y格式。但是,如果服务器和客户端使用不同的格式(例如,美国格式为m/d/y的服务器和德语格式为d/m/y的客户端),则会找到错误数量的Lotus Notes条目。
这是因为我使用getLocalTime()将日期转换为本地字符串,然后使用@TextToTime()创建日期范围。
有没有办法找出服务器使用的日期格式? 或者有没有办法避免日期到字符串转换完全?我想传入两个Lotus DateTime对象,并让服务器根据需要解码它们。
import lotus.domino.*;
Session session = NotesFactory.createSession((String)null, (String)null, password);
Database db = session.getDatabase(dominoServer, mailfile, false);
// Get our start and end query dates in Lotus Notes format. We will query
// using the localized format for the dates.
lotus.domino.DateTime minStartDateLN = session.createDateTime(minStartDate);
lotus.domino.DateTime maxEndDateLN = session.createDateTime(maxEndDate);
// Query Lotus Notes to get calendar entries in our date range.
// Here is an overview of this SELECT:
// @IsAvailable(CalendarDateTime) is true if the LN document is a calendar entry
// @Explode splits a string based on the delimiters ",; "
// The operator *= is a permuted equal operator. It compares all entries on
// the left side to all entries on the right side. If there is at least one
// match, then true is returned. Explode is used because the CalendarDateTime
// field can have many dates separated by ";" (e.g. for recurring meetings).
String calendarQuery = "SELECT (@IsAvailable(CalendarDateTime) & (@Explode(CalendarDateTime) *= @Explode(@TextToTime(\""
+ minStartDateLN.getLocalTime()
+ "-" + maxEndDateLN.getLocalTime() + "\"))))";
DocumentCollection queryResults = db.search(calendarQuery);
我试过了,如果我只是查询一个日期,它会起作用。不幸的是,我永远不知道如何使用@Date格式指定日期范围(从头到尾)。仅供参考:我现在发布了一个可行的解决方案。 – 2012-03-06 13:43:42