当前位置: 首页>>代码示例>>Java>>正文


Java Calendar类代码示例

本文整理汇总了Java中org.quartz.Calendar的典型用法代码示例。如果您正苦于以下问题:Java Calendar类的具体用法?Java Calendar怎么用?Java Calendar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Calendar类属于org.quartz包,在下文中一共展示了Calendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCalendar

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Update a calendar.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param calendarName
 *          the name for the new calendar
 * @param calendar
 *          the calendar
 * @return the number of rows updated
 * @throws IOException
 *           if there were problems serializing the calendar
 */
public int updateCalendar(Connection conn, String calendarName,
        Calendar calendar) throws IOException, SQLException {
    ByteArrayOutputStream baos = serializeObject(calendar);

    PreparedStatement ps = null;

    try {
        ps = conn.prepareStatement(rtp(UPDATE_CALENDAR));
        setBytes(ps, 1, baos);
        ps.setString(2, calendarName);

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:32,代码来源:StdJDBCDelegate.java

示例2: applyMisfire

import org.quartz.Calendar; //导入依赖的package包/类
boolean applyMisfire(TriggerWrapper tw) throws JobPersistenceException {
  long misfireTime = System.currentTimeMillis();
  if (getMisfireThreshold() > 0) {
    misfireTime -= getMisfireThreshold();
  }

  Date tnft = tw.getNextFireTime();
  if (tnft == null || tnft.getTime() > misfireTime
      || tw.getMisfireInstruction() == Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY) { return false; }

  Calendar cal = null;
  if (tw.getCalendarName() != null) {
    cal = retrieveCalendar(tw.getCalendarName());
  }

  signaler.notifyTriggerListenersMisfired(tw.getTriggerClone());

  tw.updateAfterMisfire(cal, triggerFacade);

  if (tw.getNextFireTime() == null) {
    tw.setState(TriggerState.COMPLETE, terracottaClientId, triggerFacade);
    signaler.notifySchedulerListenersFinalized(tw.getTriggerClone());
    timeTriggers.remove(tw);
  } else if (tnft.equals(tw.getNextFireTime())) { return false; }

  return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:DefaultClusteredJobStore.java

示例3: insertCalendar

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Insert a new calendar.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param calendarName
 *          the name for the new calendar
 * @param calendar
 *          the calendar
 * @return the number of rows inserted
 * @throws IOException
 *           if there were problems serializing the calendar
 */
public int insertCalendar(Connection conn, String calendarName,
        Calendar calendar) throws IOException, SQLException {
    //log.debug( "Inserting Calendar " + calendarName + " : " + calendar
    // );
    ByteArrayOutputStream baos = serializeObject(calendar);
    byte buf[] = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);

    PreparedStatement ps = null;

    try {
        ps = conn.prepareStatement(rtp(INSERT_CALENDAR));
        ps.setString(1, calendarName);
        ps.setBinaryStream(2, bais, buf.length);

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:36,代码来源:PointbaseDelegate.java

示例4: setDayExcluded

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Redefine a certain day to be excluded (true) or included (false).
 * </p>
 */
public void setDayExcluded(java.util.Calendar day, boolean exclude) {
    if (exclude) {
        if (isDayExcluded(day)) {
            return;
        }

        excludeDays.add(day);
        dataSorted = false;
    } else {
        if (!isDayExcluded(day)) {
            return;
        }

        removeExcludedDay(day, true);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AnnualCalendar.java

示例5: compare

import org.quartz.Calendar; //导入依赖的package包/类
public int compare(java.util.Calendar c1, java.util.Calendar c2) {
  
  int month1 = c1.get(java.util.Calendar.MONTH);
  int month2 = c2.get(java.util.Calendar.MONTH);
  
  int day1 = c1.get(java.util.Calendar.DAY_OF_MONTH);
  int day2 = c2.get(java.util.Calendar.DAY_OF_MONTH);
  
  if (month1 < month2) {
      return -1;
  }
  if (month1 > month2) {
      return 1; 
  }
  if (day1 < day2) {
      return -1;
  }
  if (day1 > day2) {
      return 1;
  }
  return 0;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AnnualCalendar.java

示例6: isTimeIncluded

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Determine whether the given time (in milliseconds) is 'included' by the
 * Calendar.
 * </p>
 *
 * <p>
 * Note that this Calendar is only has full-day precision.
 * </p>
 */
@Override
public boolean isTimeIncluded(long timeStamp) {
    if (excludeAll == true) {
        return false;
    }

    // Test the base calendar first. Only if the base calendar not already
    // excludes the time/date, continue evaluating this calendar instance.
    if (super.isTimeIncluded(timeStamp) == false) { return false; }

    java.util.Calendar cl = createJavaCalendar(timeStamp);
    int wday = cl.get(java.util.Calendar.DAY_OF_WEEK);

    return !(isDayExcluded(wday));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:WeeklyCalendar.java

示例7: getNextIncludedTime

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Determine the next time (in milliseconds) that is 'included' by the
 * Calendar after the given time.
 * </p>
 * 
 * <p>
 * Note that this Calendar is only has full-day precision.
 * </p>
 */
@Override
public long getNextIncludedTime(long timeStamp) {

    // Call base calendar implementation first
    long baseTime = super.getNextIncludedTime(timeStamp);
    if ((baseTime > 0) && (baseTime > timeStamp)) {
        timeStamp = baseTime;
    }

    // Get timestamp for 00:00:00
    java.util.Calendar day = getStartOfDayJavaCalendar(timeStamp);
    while (isTimeIncluded(day.getTime().getTime()) == false) {
        day.add(java.util.Calendar.DATE, 1);
    }

    return day.getTime().getTime();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HolidayCalendar.java

示例8: doUpdateOfMisfiredTrigger

import org.quartz.Calendar; //导入依赖的package包/类
private void doUpdateOfMisfiredTrigger(Connection conn, SchedulingContext ctxt, Trigger trig, boolean forceState, String newStateIfNotComplete, boolean recovering) throws JobPersistenceException {
    Calendar cal = null;
    if (trig.getCalendarName() != null) {
        cal = retrieveCalendar(conn, ctxt, trig.getCalendarName());
    }

    schedSignaler.notifyTriggerListenersMisfired(trig);

    trig.updateAfterMisfire(cal);

    if (trig.getNextFireTime() == null) {
        storeTrigger(conn, ctxt, trig,
            null, true, STATE_COMPLETE, forceState, recovering);
    } else {
        storeTrigger(conn, ctxt, trig, null, true, newStateIfNotComplete,
                forceState, false);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:19,代码来源:JobStoreSupport.java

示例9: insertCalendar

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Insert a new calendar.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param calendarName
 *          the name for the new calendar
 * @param calendar
 *          the calendar
 * @return the number of rows inserted
 * @throws IOException
 *           if there were problems serializing the calendar
 */
@Override           
public int insertCalendar(Connection conn, String calendarName,
        Calendar calendar) throws IOException, SQLException {
    //log.debug( "Inserting Calendar " + calendarName + " : " + calendar
    // );
    ByteArrayOutputStream baos = serializeObject(calendar);
    byte buf[] = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);

    PreparedStatement ps = null;

    try {
        ps = conn.prepareStatement(rtp(INSERT_CALENDAR));
        ps.setString(1, calendarName);
        ps.setBinaryStream(2, bais, buf.length);

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:PointbaseDelegate.java

示例10: updateCalendar

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Update a calendar.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param calendarName
 *          the name for the new calendar
 * @param calendar
 *          the calendar
 * @return the number of rows updated
 * @throws IOException
 *           if there were problems serializing the calendar
 */
@Override           
public int updateCalendar(Connection conn, String calendarName,
        Calendar calendar) throws IOException, SQLException {
    //log.debug( "Updating calendar " + calendarName + " : " + calendar );
    ByteArrayOutputStream baos = serializeObject(calendar);
    byte buf[] = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);

    PreparedStatement ps = null;

    try {
        ps = conn.prepareStatement(rtp(UPDATE_CALENDAR));
        ps.setBinaryStream(1, bais, buf.length);
        ps.setString(2, calendarName);

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:PointbaseDelegate.java

示例11: triggered

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Called when the <code>{@link Scheduler}</code> has decided to 'fire'
 * the trigger (execute the associated <code>Job</code>), in order to
 * give the <code>Trigger</code> a chance to update itself for its next
 * triggering (if any).
 * </p>
 * 
 * @see #executionComplete(JobExecutionContext, JobExecutionException)
 */
@Override
public void triggered(Calendar calendar) {
    timesTriggered++;
    previousFireTime = nextFireTime;
    nextFireTime = getFireTimeAfter(nextFireTime);

    while (nextFireTime != null && calendar != null
            && !calendar.isTimeIncluded(nextFireTime.getTime())) {
        
        nextFireTime = getFireTimeAfter(nextFireTime);

        if(nextFireTime == null)
            break;
        
        //avoid infinite loop
        java.util.Calendar c = java.util.Calendar.getInstance();
        c.setTime(nextFireTime);
        if (c.get(java.util.Calendar.YEAR) > YEAR_TO_GIVEUP_SCHEDULING_AT) {
            nextFireTime = null;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:SimpleTriggerImpl.java

示例12: computeFirstFireTime

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Called by the scheduler at the time a <code>Trigger</code> is first
 * added to the scheduler, in order to have the <code>Trigger</code>
 * compute its first fire time, based on any associated calendar.
 * </p>
 * 
 * <p>
 * After this method has been called, <code>getNextFireTime()</code>
 * should return a valid answer.
 * </p>
 * 
 * @return the first time at which the <code>Trigger</code> will be fired
 *         by the scheduler, which is also the same value <code>getNextFireTime()</code>
 *         will return (until after the first firing of the <code>Trigger</code>).
 *         </p>
 */
@Override
public Date computeFirstFireTime(Calendar calendar) {
    nextFireTime = getStartTime();

    while (nextFireTime != null && calendar != null
            && !calendar.isTimeIncluded(nextFireTime.getTime())) {
        nextFireTime = getFireTimeAfter(nextFireTime);
        
        if(nextFireTime == null)
            break;
        
        //avoid infinite loop
        java.util.Calendar c = java.util.Calendar.getInstance();
        c.setTime(nextFireTime);
        if (c.get(java.util.Calendar.YEAR) > YEAR_TO_GIVEUP_SCHEDULING_AT) {
            return null;
        }
    }
    
    return nextFireTime;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:SimpleTriggerImpl.java

示例13: scheduleJob

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Schedule the given <code>{@link org.quartz.Trigger}</code> with the
 * <code>Job</code> identified by the <code>Trigger</code>'s settings.
 * </p>
 * 
 * @throws SchedulerException
 *           if the indicated Job does not exist, or the Trigger cannot be
 *           added to the Scheduler, or there is an internal Scheduler
 *           error.
 */
public Date scheduleJob(Trigger trigger)
    throws SchedulerException {
    validateState();

    if (trigger == null) {
        throw new SchedulerException("Trigger cannot be null");
    }

    OperableTrigger trig = (OperableTrigger)trigger;
    
    trig.validate();

    Calendar cal = null;
    if (trigger.getCalendarName() != null) {
        cal = resources.getJobStore().retrieveCalendar(trigger.getCalendarName());
        if(cal == null) {
            throw new SchedulerException(
                "Calendar not found: " + trigger.getCalendarName());
        }
    }
    Date ft = trig.computeFirstFireTime(cal);

    if (ft == null) {
        throw new SchedulerException(
                "Based on configured schedule, the given trigger '" + trigger.getKey() + "' will never fire.");
    }

    resources.getJobStore().storeTrigger(trig, false);
    notifySchedulerThread(trigger.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trigger);

    return ft;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:QuartzScheduler.java

示例14: updateCalendar

import org.quartz.Calendar; //导入依赖的package包/类
/**
 * <p>
 * Update a calendar.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param calendarName
 *          the name for the new calendar
 * @param calendar
 *          the calendar
 * @return the number of rows updated
 * @throws IOException
 *           if there were problems serializing the calendar
 */
public int updateCalendar(Connection conn, String calendarName,
        Calendar calendar) throws IOException, SQLException {
    //log.debug( "Updating calendar " + calendarName + " : " + calendar );
    ByteArrayOutputStream baos = serializeObject(calendar);
    byte buf[] = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);

    PreparedStatement ps = null;

    try {
        ps = conn.prepareStatement(rtp(UPDATE_CALENDAR));
        ps.setBinaryStream(1, bais, buf.length);
        ps.setString(2, calendarName);

        return ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:35,代码来源:PointbaseDelegate.java

示例15: retrieveCalendar

import org.quartz.Calendar; //导入依赖的package包/类
@Override
public Calendar retrieveCalendar(String calName) throws JobPersistenceException {
  try {
    return realJobStore.retrieveCalendar(calName);
  } catch (RejoinException e) {
    throw new JobPersistenceException("Calendar retrieval failed due to client rejoin", e);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AbstractTerracottaJobStore.java


注:本文中的org.quartz.Calendar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。