SIMPLE カレンダーおよび CRON カレンダーは、J2EE アプリケーションから使用できます。 このトピックでは、そのプロセスについて説明します。
デフォルトのスケジューラー・カレンダーを使用すると、デフォルトの UserCalendarHome EJB ホーム・オブジェクトが検索され、UserCalendar Bean が作成され、applyDelta() メソッドが呼び出されます。applyDelta メソッド、 および SIMPLE カレンダーと CRON カレンダーの構文の詳細については、トピック UserCalendar インターフェースを参照してください。
例:
import java.util.Date; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import com.ibm.websphere.scheduler.UserCalendar; import com.ibm.websphere.scheduler.UserCalendarHome; // Create an initial context InitialContext ctx = new InitialContext(); // Lookup and narrow the default UserCalendar home. UserCalendarHome defaultCalHome=(UserCalendarHome) PortableRemoteObject.narrow(ctx.lookup( UserCalendarHome.DEFAULT_CALENDAR_JNDI_NAME), UserCalendarHome.class); // Create the default UserCalendar instance. UserCalendar defaultCal = defaultCalHome.create(); // Calculate a date using CRON based on the current // date and time. Return the next date that is // Saturday at 2AM Date newDate = defaultCal.applyDelta(new Date(), "CRON", "0 0 2 ? * SAT");