java - 独立于日期区域设置查询 Lotus Domino 日历条目

标签 java lotus-notes lotus-domino lotus-formula

我有 Java 代码,可以从 Lotus Notes 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);

最佳答案

您可以使用 native Java 或 Lotus DateTime 方法从最小值和最大值中提取各个年、月、日、小时、分钟和秒值,然后使用 @Date(year,月、日、时、分、秒)

关于java - 独立于日期区域设置查询 Lotus Domino 日历条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9316573/

相关文章:

parent - 引用父文档的公式在计算字段中工作,而不是作为默认值

javascript - xpages 中的 Lotus Notes 客户端链接和浏览器链接用于下载服务器目录中存储的文件

lotus-notes - Lotus Notes 数据库设计解锁

lotus-notes - Lotus Notes公式: Button Error Message

css - 停止继承特定 <div> 的字体大小

java - Lotus Notes - 标记文档行(以不同颜色突出显示该行)

java - 使用java注释和反射获取java.lang.NullPointerException

java - 并行任务批处理的设计方法

java - 序列化一个 java.awt.geom.Area

java - Multitheard的应用程序看起来可以随机运行