Lotus Notes Domino サーバーから (開始日と終了日の範囲に基づいて) カレンダー エントリをクエリする Java コードがあります。以下は、コードの簡略化されたバージョンです。
ローカル クライアントと同じ日付形式の Domino サーバーにクエリを実行すると、サーバーとクライアントの両方が m/d/y 形式を使用するなど、すべて問題ありません。ただし、サーバーとクライアントが異なる形式を使用している場合 (たとえば、米国形式の m/d/y のサーバーとドイツ語形式の d/m/y のクライアント)、誤った数の Lotus Notes エントリが検出されます。
これは、getLocalTime() を使用して日付をローカル文字列に変換し、@TextToTime() を使用して日付範囲を作成しているためです。
サーバーが使用している日付形式を調べる方法はありますか? または、日付から文字列への変換を完全に回避する方法はありますか? 2 つの 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);