java - How to write a cron expression or Set a timer that will be executed only once in Spring? -


i sending push notifications android apps everyday morning backend spring-mvc java application. have created cron job , initialized bean in webconfig(@enablescheduling). bean send notifications everyday morning.

but if user don't read it, must send notification in evening @ particular time. otherwise shouldn't send anything. how write cron expressen or scheduler or set timer send once @ particular time, only on day?

that makes no sense launch cron process once...

pattern 0 0 hour-minute * * ? program task hour , minute, each day:

0 0 15-45 * * ?    // execute task @ 15:45 

but achieve this, @ this answer shows how use timer create thread runs when needed:

private static class mytimetask extends timertask {         public void run()     {         //write code here     } }  public static void main(string[] args) {     //the date , time @ want execute     dateformat dateformatter = new simpledateformat("yyyy-mm-dd hh:mm:ss");     date date = dateformatter .parse("2012-07-06 13:05:45");      //now create time , schedule     timer timer = new timer();     timer.schedule(new mytimetask(), date); } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -