WAS v8.5 > Reference > Administrator examples

Example: Use default scheduler calendars

The SIMPLE and CRON calendars can be used from any J2EE application by...

  1. Looking-up the UserCalendarHome object
  2. Creating the UserCalendar bean
  3. Calling the applyDelta() method.

For example...

import java.util.Date;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import com.ibm.websphere.scheduler.UserCalendar;
import com.ibm.websphere.scheduler.UserCalendarHome;

ctx = new InitialContext();
UserCalendarHome defaultCalHome=(UserCalendarHome)
                 PortableRemoteObject.narrow(ctx.lookup(UserCalendarHome.DEFAULT_CALENDAR_JNDI_NAME), 
                 UserCalendarHome.class);

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


Related concepts:
Scheduler calendars
Scheduler daemon
Install default scheduler calendars
Manage schedulers
Develop and schedule tasks
UserCalendar interface
Interoperate with schedulers


+

Search Tips   |   Advanced Search