1

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

3 に答える 3

1

検索する日付の書式を設定してみてください - すべての場所で共通の書式になります: @TextToTime(@Text(CalendarDateTime))

もう 1 つのアイデアは、Ytria の ScanEZ のようなツールを使用して、カレンダー エントリのすべてのフィールド/データを表示することです。検索できる一般的な形式で保存された日付を持つフィールドがあると信じています。

于 2012-02-25T23:48:13.960 に答える
1

ネイティブの Java または Lotus の DateTime メソッドを使用して、min と max から個々の年、月、日、時、分、および秒の値を抽出し、@Date(year,month,day を使用してクエリで日付を作成できます。 、時、分、秒)

于 2012-02-17T01:34:15.793 に答える
1

Java の lotus.domino.International クラス (別名 NotesInternational クラス) を使用して、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); 
于 2012-03-06T13:39:31.180 に答える