2012-02-16 9 views
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); 

答えて

0

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

あなたはネイティブJavaやロータスのDateTimeメソッドのいずれかを使用して、最小値と最大値から個々の年、月、日、時、分、秒の値を抽出して、クエリが使用して日付を構築できます@日付(年、月、日、時、分、秒)

+0

私はそれを試みました。私が1つの日付だけを照会していたら、それはうまくいっていました。残念ながら、@日付形式を使用して日付範囲を指定する方法(開始から終了まで)を決めることはできません。 FYI:私は今、機能するソリューションを掲載しました。 –

1

は、あなたが探している日付をフォーマットしよう - それは、すべての場所で共通のフォーマットになります: @TextToTime(@Text(CalendarDateTime))

もう1つのアイデアは、YtriaのScanEZのようなツールを使用して、カレンダーエントリ内のすべてのフィールド/データを表示することです。あなたが検索できる共通のフォーマットで保存された日付を持つフィールドがあると考えてください。

+0

一般的なフォーマットを見つけようとしました。 yyyy-mm-ddThh:mm:ssですが、すべてのDomino Serverで動作する形式を見つけることはできませんでした。 FYI:私は今、機能するソリューションを掲載しました。 –

関連する問題