I was testing CronTimeTrigger and found a bug:
Assume today is 29th July 2001
You set a cron time trigger to 5th Feb 2002, then 
CronTimeTrigger will set next time running to 
5th March 2002, not 5th Feb 2002

I think that :
        if( -1 != m_month ) {
            next.set( Calendar.MONTH, m_month );
            if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
            if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
        }
will set object next to 1st March 2002, as Feb 2002 has only 28 days!

In order to solve that problem, I check if the m_month has enough 
day,if not i set next to max days of m_month, like:
        if( -1 != m_month ) {
            // check if start: m_month, has enough days
            Calendar cal_month = (GregorianCalendar)next.clone();
            cal_month.set( Calendar.DAY_OF_MONTH, 1 );
            cal_month.set( Calendar.MONTH, m_month );
            int max_day_of_month = cal_month.getActualMaximum( 
Calendar.DAY_OF_MONTH );
            if (max_day_of_month < next.get( Calendar.DAY_OF_MONTH )) {
              next.set( Calendar.DAY_OF_MONTH, max_day_of_month );
            }
            // check if end
            next.set( Calendar.MONTH, m_month );
            if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
            if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
        }

best regards

begin:vcard
n:Huber;Bernhard
fn:Bernhard Huber
version:2.1
email;internet:[EMAIL PROTECTED]
end:vcard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to