Checking the time before code execution..

public boolean checker(int mins) {
          int minutes = 0;
          while (mins!=minutes) {
               Calendar cal = new GregorianCalendar();
                   minutes = cal.get(Calendar.MINUTE);
          return true;
     }I am building a time-sensitive embargo application which will run in the background and constantly check the time until a certain time is reached when it will automatically update a website by sending a file by ftp.
The above method is the time checker which, when called, will only allow the ftp code to execute when it returns - which is when the required time (in minutes) is reached.
My question is this: Is this the best way to achieve this or will it tie up valuable resources. Can anyone suggest a better way ?
Thanks

import java.util.Timer;
import java.util.TimerTask;
  * Simple demo that uses java.util.Timer to schedule a task to execute
  * once 5 seconds have passed.
public class Reminder {
     Timer timer;
     public Reminder(int seconds) {
         timer = new Timer();
         timer.schedule(new RemindTask(), seconds*1000);
     class RemindTask extends TimerTask {
         public void run() {
             System.out.println("Time's up!");
       timer.cancel(); //Terminate the timer thread
     public static void main(String args[]) {
   System.out.println("About to schedule task.");
         new Reminder(5);
   System.out.println("Task scheduled.");
}

Similar Messages

  • Hi, I just picked up my phone to check the time, and it was off, which was weird because I just checked it a minute or so before. i tried to turn it on, which didn't work, then i plugged it in, and it has still shown no sign of life.. what do i do?

    Hi, I just picked up my phone to check the time, and it was off, which was weird because I just checked it a minute or so before. i tried to turn it on, which didn't work, then i plugged it in, and it has still shown no sign of life.. what do i do?

    Try resetting it: hold the on/off and home buttons 10-20 seconds until you see the Apple logo, ignoring the off slider that appears first, then release.

  • Hi please help i pressed my home button on my i phone 5  this morning to check the time and my phone went big(like its zoomed in) i have switched it off but when it came back on again its still got a big screen any ideas?

    hi please help i pressed my home button on my i phone 5 this morning to check the time and the screen went big as if its zoomed in i have switched the phone off but when it came back on the screen is still big i cant connect to i tunes either as i have a pass code on my phone i cant type it in as the screen is to big. please has anyone got any ideas on how to fix this.

    tweetypie80 wrote:
    thank you for your help
    You're welcome.

  • Timer works if I set the time before the current one

    Hi,
    I've got a block that is part of an actionListener that has 4 buttons, anyway I want the timer to execute something exactly at the time I set it.....but in the code that I have it also executes if i set the time before the current time
    Here's the segmant:
    private class ButtonResponder implements ActionListener
              public void actionPerformed(ActionEvent event) 
                    if (event.getSource() == exitButton)
                                  System.exit(0);
                   if(event.getSource() == setButton)
                        int hour = Integer.parseInt(hours[hourComboBox.getSelectedIndex()]);
                        int min = Integer.parseInt(minutes[minuteComboBox.getSelectedIndex()]);
                        Calendar calendar = Calendar.getInstance();
                        calendar.set(Calendar.HOUR_OF_DAY, hour);
                        calendar.set(Calendar.MINUTE, min);
                        calendar.set(Calendar.SECOND, 0);
                        Date time = calendar.getTime();
                    timer = new java.util.Timer();
                        timer.schedule(new TimerTask()
                             public void run()
                                  JOptionPane.showMessageDialog(null, "it is time");
                        , time, 5*1000);
                   if (event.getSource() == cancelButton)
                        timer.cancel();
              }So if I put zeros in hours and minutes it will execute immediately....how can I make execute at the exact time (so that if the time now is 2:00 and I set it to 1:00 it only executes the next day??
    Message was edited by:
    Octavian

    Bump the day if the time is less than current time.
    Kaj

  • Today I was shopping and I went to check the time on my Iphone but it had shut itself off for no reason and now it won't turn back on. What should I do?

    Today I was shopping and I went to check the time on my Iphone but it had shut itself off for no reason and now it won't turn back on. What should I do?

    It could have powered off. Try holding the sleep button down for a few seconds until the apple logo appears to restart it

  • I did download the new version of adobe but a massage showed all the time (Before viewing PDF documents in this browser you must launch Adobe Reader and accept the End User License Agreement, then Quit and relaunch the browser)

    i did download the new version of adobe but a massage showed all the time (Before viewing PDF documents in this browser you must launch Adobe Reader and accept the End User License Agreement, then Quit and relaunch the browser)

    You downloaded Adobe... what? Adobe has tons of applications.
    Which Adobe product did you download?
    Clinton

  • HT1688 my Iphone 4 quit working.  It will not recharge and it was not low on charge when it quit.  It was sitting on a table. I checked the time and then it never worked again.

    My Iphone 4 quit.  it has a charge.  it was on a table.  i checked the time and it never came on again.
    Please help.
    Sharon

    Hold the HOME and SLEEP buttons at the same time until an Apple logo appears. If it hasn't appeared after 20 seconds of holding charge it for 15 minutes with the wall charger and try again.

  • So just today I was going to check the time on my iPod Touch 4th Gen, and I noticed that the lock button was not functioning, on closer inspection, it appeared as it had just gotten stuck in the pushed position.

    This afternoon I was doing things and needed to check the time, I pressed the lock button so it would show the time, but the button would not press. I looked closly and saw the button was stuck as if it was pushed and didn't come back out. I CANNOT lock my iPod using the button.
    More details:
    -4th gen. iPod touch
    -Small dent near lock button
    -32GB
    -2 Years old.
    PLEASE HELP

    First, have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?
    Next
    - Make an appointment at the Genius Bar of an Apple store. Maybe they can unstick it
    Apple Retail Store - Genius Bar                          
    If they can't
    Apple will exchange your iPod for a refurbished one for $99. They do not fix yours.
    Apple - iPod Repair price              
    A third-party place like the following maybe less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Fix it yourself if you are up to it
    iPod Touch Repair – iFixit

  • TS1702 when i am trying to download new game from app store it showing "to check the time and date settings"?

    when i am trying to download new game from app store it showing "to check the time and date settings"?

    planb77  The OP said he has iOS 3. The Automatic in Settings>General>Time and Date was introduced in iOS 5. The OP just has to see if the time and date, included time zone, are correct.

  • Does iMovie HD retrieve the time/date code for actual recrding date of a c

    Dear Apple Discussions,
    I wish to know if iMovie HD retrieves the original recording time and date of a clip as a part of the time/date code, as do other video editors.
    When click on a clip and select properties, the capture time and date is displayed.
    Matti Haveri posted a response, but hers related to the capture date.
    I wish to know the actual time and date that a clip was recorded by my DV camcorder. Can anyone out the assist me?
    Owen Cobb
    (The Clemmons Kid)

    iMovie does keep the original recording time and date of a clip as a part of the time/date code.
    When click on a clip and select properties, the capture time and date is displayed.
    Really? With my setup I see the original recording date & time.
    But wait, what kind of footage do you have? Originally analog footage converted to DV? THEN the digitizing device usually labels the DV with the digitizing date.
    http://discussions.apple.com/message.jspa?messageID=4563204#4563204

  • HT4515 Is there a way to Increase the time before a call is forwarded?

    Is there a way to increase the time before a call is forwarded to another number?

    That's a carrier feature. Contact your carrier.

  • I enter specific times on the computer icloud calendar and the times are three (3) hours different when viewed on my iphone. I have checked the time settings on the iphone and it is correct (EST).Where do I go next?

    I have entered dates and specific times on my computers icloud calendar.  When I view the dates and times on my iphone the times are three (3) hours later. I have checked the time zone settings on my iphone and it is correct (EST).  Where do I go next?

    Restoring is the answer. It sounds as if there is a rogue process constantly draining your battery.
    The issue you face is that, if you restore your backup thereafter, you risk the problem coming straight back with your files.
    Store your files individually and it is time to start fresh.

  • Increase the time before call diverts to answer phone

    Is there anyway in which the amount of time that the blackerry rings for can be increased before the blackberry diverts the call to the voicemail?
    Thanks for any help in advance 

    I am sorry I do not have the definitive fix, however, I can give one pearl of advice. 
    By making sure your phone is in ring only or vibrate only will increase the amount of time each will perform prior to rolling over to VM. 
    Example of this is when in vibrate and ring, your phone will do shortened performances of each before timing out.  If you are not relying on vibration to sense your phone, you will loose all the time before you hear the ring tone. 
    Hope this helps!

  • How to prevent re-loading the jsp before servlet execution gets over

    Hi,
    From jsp, I am calling a function in js. From javascript function, I am calling a servlet in background frame after doing client-side validation. Before the servlet execution gets over, javascript function is getting over and it starts reloading the jsp again.
    I want to restrict the re-loading of jsp till the background servlet execution gets over.
    In background servlet, I am doing query execution.
    Its urgent. Please help me with this question.
    Thanks in advance,
    Sri

    For the time being, one suggestion would be to time how long the sql statement takes to execute. Lets say 1.5 seconds.
    Go into your javascript function and add say a 1.5 + .5 = 2.0 second delay before the javascript function completes (submits the page).
    This is a temporary fix. I doubt there is a better fix to this without knowing a great deal of AJAX and how it handles asynchronous communications.
    I don't know what the javascript function for creating a 2.0 second delay, but I imagine there is one in a javascript book.
    Once you implement the temporary fix above, I suggest you redesign your project to avoid these asynchronous problems by treating
    all your JSP pages as simple display pages and not embed any business logic in them (or in the javascripts). All processing should be done back on the server via servlets.

  • How do I extend the time before re-entering password.  I have it set of one hour at present but would like to extend that.

    I have a 2014 Mac Mini 1.4G, 4GB, 500GB.  I bought this recently but am new to Mac.  How can I extend the down time before having to re-enter my password. I have it set to 1 hr but I need more time because of using it intermittently throughout the day.  I can't seem to get back to where I set that in the first place.
    Help!!
    Ozarksguy

    You can go to System Preferences > Security & Privacy and make your choices:

Maybe you are looking for

  • Error whilst installing XMLParser for PL/SQL

    Oracle 8.1.6, AIX While installing the java archive named xmlparserv2.jar, I constantly get the message: ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler can somebody tell me why? I've tried to check my classpatch in all the w

  • Problems with switching language (Mac os)

    Hello. I have Mac os 10.6.8 and two languages in input source - US and Russian. I have a sample application build with sdk 4.5.1 Air 3. When I using this application russian language is always disabled. It enabled only if I'm focused on text input co

  • Creating psd animation

    I imported  "Image Sequence"  inPS then created the sequence and adjusted the layers and timeline. Two questions: 1) How do I revert all the frames (the are in the wrong order) 2) from the file in Photoshop format but I can't figure out how to save a

  • Project files and Media files on same disk OK?

    For some reason I have it in my head that having my project files on the same disk as I have the media files on is a bad idea. Is that true? Thanks.

  • I cannot connect to the add-ons page to get new ones

    When I go to Tools, add-ons, I get the "What are add-ons?" and it tells me that when I connect to the internet the panel will feature many options. I am online why can I not connect to the add-ons page? Dan