if( startTime < now) { startTime += 7 * 24 * 60 * 60 * 1000; }
    public void configure( Configuration config ) throws ConfigurationException    {        _timers = new ArrayList();        _services = new ArrayList();        String nextKey = null;        Date today = new Date();        for (Iterator it = config.getKeys(); it.hasNext();)        {            String currentKey = StringUtil.defaultIfNull( nextKey, (String) it.next() );            Configuration subSet = config.getSubset( currentKey );            String clazz = config.getString( currentKey );            Service service = null;            boolean autostart = subSet.getBoolean( "autostart", false );            int restartOnFailure = subSet.getInt( "restartOnFailure", 0 );            long startTime = System.currentTimeMillis() + 60000;            long schedulePeriod = -1;            String[] schedule = subSet.getStringArray( "schedule" );            String period = "ONCE";            try            {                service = (Service) Class.forName( clazz ).newInstance();            }            catch ( ClassNotFoundException e )            {                logger.error( "Unable to locate service " + clazz + ". Check your configuration.", e );                throw new ConfigurationException( e.getMessage() );            }            catch ( Exception e )            {                logger.error( "Unable to start service " + clazz + ". Check your configuration.", e );                throw new ConfigurationException( e.getMessage() );            }            //SCHEDULING REQUIRED?            if (schedule != null && schedule.length > 0)            {                long now = System.currentTimeMillis();                Date date = null;                                                if( schedule.length > 1)                {                    period = schedule[1];                }                try                {                    if (period.equalsIgnoreCase( "ONCE" ))                    {                        schedulePeriod = -1;                        df.applyPattern( "HH:mm:ss" );                        startTime = df.parse( schedule[0] ).getTime();                    }                    else if (period.equalsIgnoreCase( "EVERY" ))                    {                        df.applyPattern( "HH:mm:ss" );                        date = df.parse( schedule[0] );                        long start = date.getHours() * 60 * 60 * 1000;                        start += date.getMinutes() * 60 * 1000;                        start += date.getSeconds() * 1000;                        startTime = now;                        schedulePeriod = start;                    }                    else if (period.equalsIgnoreCase( "DAYLY" ))                    {                        df.applyPattern( "HH:mm:ss" );                        date = df.parse( schedule[0] );                        date.setYear(today.getYear());                        date.setMonth(today.getMonth());                        date.setDate(today.getDate());                        startTime = date.getTime();                        schedulePeriod = 24 * 60 * 60 * 1000;                    }                    else if (period.equalsIgnoreCase( "WEEKLY" ))                    {                        df.applyPattern( "EEE, HH:mm:ss" );                        date = df.parse( schedule[0] );                        date.setYear(today.getYear());                        date.setMonth(today.getMonth());                        date.setDate(today.getDate());                        startTime = date.getTime();                        schedulePeriod = 7 * 24 * 60 * 60 * 1000;                    }                                        Timer timer = new Timer();                    if (schedulePeriod != -1)                    {                        timer.scheduleAtFixedRate( new ServiceTask( service, restartOnFailure ), startTime, schedulePeriod );                        logger.info("Scheduled service " + currentKey + ". First start: " + new Date(startTime).toLocaleString() + " Then every: " + (schedulePeriod/1000/60) + " minutes" );                    }                    else                    {                        timer.schedule( new ServiceTask( service, restartOnFailure ), new Date( startTime ) );                        logger.info("Scheduled service for single start" + currentKey + ". Start: " + new Date(startTime).toLocaleString());                                        }                    _timers.add( timer );                                    }                catch ( ParseException e )                {                    logger.error( "Error while parsing start time for service " + clazz + "! The service will not be scheduled, please review your configuration.", e );                }            }            //NO SCHEDULING REQUIRED, START SERVICE IMMEDIATELY BUT ONLY ONCE            else if (autostart)            {                try                {                    service.start();                    _services.add( service );                    logger.info("Started service without scheduling: " + currentKey);                }                catch ( Exception e )                {                    logger.error( "Error occured while starting service " + clazz, e );                }            }            //loop through properties until next service found            nextKey = currentKey;            while ( nextKey.startsWith( currentKey ) && it.hasNext() )            {                nextKey = (String) it.next();            }        }    }