static public MailVetterDailyNotificationTask scheduleTask ( CouchDesignDocument serverDesignDoc , MailNotification mailNotification ) { Timer timer = new Timer ( ) ; MailVetterDailyNotificationTask installedTask = new MailVetterDailyNotificationTask ( timer , serverDesignDoc , mailNotification ) ; Calendar calendar = Calendar . getInstance ( ) ; // now Date now = calendar . getTime ( ) ; calendar . set ( Calendar . HOUR_OF_DAY , 0 ) ; calendar . set ( Calendar . MINUTE , 0 ) ; calendar . set ( Calendar . SECOND , 0 ) ; calendar . set ( Calendar . MILLISECOND , 0 ) ; Date start = calendar . getTime ( ) ; while ( start . getTime ( ) < now . getTime ( ) ) { start = new Date ( start . getTime ( ) + DAILY_PERIOD ) ; } if ( true ) { timer . schedule ( installedTask , start , DAILY_PERIOD ) ; // } else { // This code to test with a shorter period // start = new Date( now.getTime() + (1000*30) ); // timer.schedule(installedTask, start, 1000 * 30); } // Log { SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; String startString = sdf . format ( start ) ; logger . info ( "Vetter daily notifications set to start at: " + startString ) ; } return installedTask ; }
24 hours in ms