我正在尝试获取给定日期的日历条目。该代码可以正常工作,但是我输入了错误的日历日期。我确信这个公式是正确的,但无论如何都会感谢任何帮助。这是代码。
long startTime;
long endTime;
String searchFormula;
DocumentCollection dc_CalendarEntries;
System.out.println("Getting default TimeZone");
TimeZone calTZ = TimeZone.getDefault();
GregorianCalendar startDay = new GregorianCalendar(calTZ);
startDay.set(startDay.get(1), startDay.get(2), startDay.get(5), 0, 0, 0);
startTime = startDay.getTime().getTime();
GregorianCalendar endDay = new GregorianCalendar(calTZ);
endDay.setTime(startDay.getTime());
endDay.add(5, 1);
endTime = endDay.getTime().getTime();
System.out.println("Creating Search Formula");
StringBuffer searchFormulaStringBuffer = new StringBuffer("@IsAvailable(CalendarDateTime)");
searchFormulaStringBuffer.append(" & StartDateTime >= @Date(").append(startDay.get(1)).append("; ").append(startDay.get(2) + 1).append("; ").append(startDay.get(5)).append("; ").append(startDay.get(10)).append("; ").append(startDay.get(12)).append("; ").append(startDay.get(13)).append(")");
searchFormulaStringBuffer.append(" & EndDateTime <= @Date(").append(endDay.get(1)).append("; ").append(endDay.get(2) + 1).append("; ").append(endDay.get(5)).append("; ").append(endDay.get(10)).append("; ").append(endDay.get(12)).append("; ").append(endDay.get(13)).append(")");
searchFormulaStringBuffer.append(" & (AppointmentType = \"3\" | AppointmentType = \"0\")");
searchFormula = searchFormulaStringBuffer.toString();
System.out.println(searchFormula);
dc_CalendarEntries = db_Mail.search(searchFormula);
这就是应用的公式。
@IsAvailable(CalendarDateTime) & StartDateTime >= @Date(2009; 10; 3; 0; 0; 0) & EndDateTime <= @Date(2009; 10; 4; 0; 0; 0) & (AppointmentType = "3" | AppointmentType = "0")
我得到以下条目。
Test Project daily checkpoint 2009-09-08
This is a Test Meeting 2009-10-03
第二个条目是正确的并且很好,但出于某种奇怪的原因,无论我给出的日期如何,第一个条目都会不断弹出。我不确定这是我的笔记中的编码问题还是某些配置问题。