java - How do I have my method execute at a specific date/time? -


right have method (correctly) updates label on gui count down user input form text box:

   private void bendstopcounter() throws awtexception {         thread counter = new thread() {            public void run() {            // timeaway user input int in miliseconds, hence conversion                (int i=(int)(timeaway/1000); i>0; i=i-1) {                    updategui(i,lblbendingstoptimer);                    try {thread.sleep(1000);} catch(interruptedexception e) {};                }            }                   public void updategui(final int i, final label lblbendingtimer) {                        display.getdefault().asyncexec(new runnable() {                             public void run() {                               lblbendingtimer.settext("time until bending stops: " + i/60 + " minutes , " + i%60 + " seconds.");                            }                        });                  }        };        counter.start();    } 

this listener button logic on gui. parses date/time form , (correctly) executes logic bendingcontroller class something:

   private void addbendinglistener()    {           executebendingbutton.addselectionlistener(new selectionadapter() {                  @override                  public void widgetselected(selectionevent e) {                        system.out.println("bending has started! lolool");                        //grabs ui values , pass them controller                        int day = datetimedmy.getday();                        int month = datetimedmy.getmonth();                        int year = datetimedmy.getyear();                        int hour = datetimehms.gethours();                        int minute = datetimehms.getminutes();                        int second = datetimehms.getseconds();                        date date = parsedate(day, month, year, hour, minute, second);                         try {                               system.out.println("waiting " + date + " happen...");                                timeaway = long.parselong(timeawayinminutes.gettext());                               timeaway = timeunit.minutes.tomillis(timeaway);                                timer.schedule(new bendercontroller(timeaway,cursormoveincrement), date);                                timeaway = timeunit.milliseconds.tomillis(timeaway);                                bendstopcounter();                        }                        catch (exception exc) {                               messagedialog.openerror(shell, "error", "hey, jerkwad, see 2 friggin' textboxs?  yeah, put valid numbers in them next time, asshole!");                               return;                        }                                            }            });    } 

my bug if user chooses start date/time anytime in future, counter starts counting down execute button pressed. bendercontroller class logic execute @ specific time, because extending timertask , using schedule() method seen above. want bendstopcounter() method use similar , start executing @ same time chosen date/time.

thoughts?

you use library quartz this. easy use , can use cron syntax easy find information on can make specific schedules.

https://quartz-scheduler.org/


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -