Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 独立于日期区域设置查询Lotus Domino日历条目_Java_Lotus Notes_Lotus Domino_Lotus Formula - Fatal编程技术网

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

Java 独立于日期区域设置查询Lotus Domino日历条目,java,lotus-notes,lotus-domino,lotus-formula,Java,Lotus Notes,Lotus Domino,Lotus Formula,我有Java代码,可以从LotusNotesDomino服务器(基于开始和结束日期范围)查询日历条目。下面是代码的简化版本 查询与本地客户机日期格式相同的Domino服务器时,一切正常,例如,服务器和客户机都使用m/d/y格式。但是,如果服务器和客户机使用不同的格式(例如,使用美国格式的服务器和使用德国格式的客户机),则会发现错误数量的Lotus Notes条目 这是因为我使用getLocalTime()将日期转换为本地字符串,然后使用@TextToTime()创建日期范围 有没有办法找出服务器

我有Java代码,可以从LotusNotesDomino服务器(基于开始和结束日期范围)查询日历条目。下面是代码的简化版本

查询与本地客户机日期格式相同的Domino服务器时,一切正常,例如,服务器和客户机都使用m/d/y格式。但是,如果服务器和客户机使用不同的格式(例如,使用美国格式的服务器和使用德国格式的客户机),则会发现错误数量的Lotus Notes条目

这是因为我使用getLocalTime()将日期转换为本地字符串,然后使用@TextToTime()创建日期范围

有没有办法找出服务器使用的日期格式? 或者有没有办法完全避免日期到字符串的转换?我想传入两个LotusDateTime对象,让服务器根据需要对它们进行解码

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);

您可以使用本机Java或Lotus DateTime方法从最小值和最大值中提取单独的年、月、日、小时、分钟和秒值,然后使用@Date(年、月、日、小时、分钟、秒)在查询中构建日期

尝试设置您正在搜索的日期的格式-因此它将是所有位置的通用格式: @TextToTime(@Text(CalendarDateTime))


另一个想法是使用像Ytria的ScanEZ这样的工具来查看日历条目中的所有字段/数据。相信有一个字段将以通用格式保存日期,您可以对其进行搜索。

有一种方法可以使用Java lotus.Domino.International类(又名notesintinternational类)在Domino服务器上查找日期格式。这是最后的工作代码

import lotus.domino.*;

Session session = NotesFactory.createSession((String)null, (String)null, password);

Database db = session.getDatabase(dominoServer, mailfile, false);

String strDateFormat;
// Get the date separator used on the Domino server, e.g. / or -
String dateSep = session.getInternational().getDateSep();

// Determine if the server date format is DMY, YMD, or MDY
if (session.getInternational().isDateDMY()) {
    strDateFormat = "dd" + dateSep + "MM" + dateSep + "yyyy";                
}
else if (session.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) & (@Explode(CalendarDateTime) *= @Explode(@TextToTime(\"" +
    dateFormat.format(startDate) + " - " + dateFormat.format(endDate) + "\"))))";

DocumentCollection queryResults = db.search(calendarQuery); 

我试图找到一种通用格式,例如yyyy-mm-ddThh:mm:ss,但始终找不到一种适用于所有Domino服务器的格式。仅供参考:我现在发布了一个有效的解决方案。我试过了,如果我只查询一个日期,它就会有效。不幸的是,我永远无法理解如何使用@date格式指定日期范围(从开始到结束)。仅供参考:我现在发布了一个有效的解决方案。