Mechanism that runs my application only at certain times of the day

Hi,
As my title suggests, i'm looking for some code that will allow me to run parts of my application only at a certain time in the day. More specifically, I want the code to run these parts of the application at 5pm only on weekdays.
I've tried various different types of loops to do this, but can't find anyway to do it.
Could somebody suggest a better way of doing it?
Thanks in advance.
Here is some example code of what I tried:
public static void main(String[] args)
     // TIMER
     Calendar cal = new GregorianCalendar();
     // Get the components of the time
     int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
     int min = cal.get(Calendar.MINUTE); // 0..59
     int today = cal.get(Calendar.DAY_OF_WEEK);
     final int RUNH = 17;
     final int RUNM = 0;
     app start = new app(); //starts the application
     while (!((hour24 == RUNH) && (min == RUNM)) || (today ==1 ) || (today == 6))
          // do nothing
     if((hour24 == RUNH) && (min == RUNM) && ((today != 1) && (today != 7))) // 5:00 on a weekday
          System.out.println ("Update Running " + hour24 + " " + min + " " + today); //runs some sort of update on the application
}

Something like this will work:
long now = System.currentTimeMillis();
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR,17);
cal.set(Calendar.MINUTE,0);
cal.set(Calendar.SECOND,0);
int day = cal.get(Calendar.DAYOFWEEK);
int yearday = cal.get(Calendar.DAYOFYEAR);
cal.set(Calendar.DAYOFYEAR,yearday + (day == Calendar.FRIDAY)? 3 : 1))
long next = cal.getTime() //don't know... maybe needs another getTime()?
Thread.currentThread.sleep(next-now);

Similar Messages

  • Automatically launch an application at a certain time of the day

    Is there any way to do that?
    Schedule a program to start at a certain time and quit at another?
    Thanks!

    Helo,
    Set up an iCal event, repeating everyday and telling him to Run Script as an alarm., and another to quit it.
    Also, this may help...
    http://www.macupdate.com/app/mac/32388/task3l

  • How can I set a passcode that is only required at certain times of the day. Ie: my child needs access for school use, but don't want her playing iPad in the middle of the night. I cannot identify a way to have the iPad turn off or require a password

    I cannot find a way to enable my child's iPad to require a passcode only at certain times of the day.
    Yes I have used the clock/timer/ countdown - great to restrict how many minutes of iPad usage they get a day.
    But as my child requires the iPad in school for class lessons the usage at school varies maybe 30 mins 1 day and a few hrs on other days
    I want the ability to say set the iPad to not work between say 7pm and 7am, ( unless a passcode is entered) so my child isn't playing games on it in the middle of the night...
    Apple I cannot see anything in the settings that performs this function
    Help

    You can Remote Lock his iPad with Find My iPad using a computer at whatever time you like.
    http://support.apple.com/kb/PH2700
    Note: The iPad may be disabled if he tries the passcode too many times.

  • Running test at certain times in the day

    I am using LabVIEW 7.1 with Windows 2000.
    I have a program that needs to run for a set amount of days. Each day this program has certain duties to perform at certain times in the day. I have it able to run for a number of days but I am still working on the time intervals between cycles. I am looking for either a certain vi or a certain method on how to do this. I appreciate your help.
    Ron Deavers, CLD

    My inclination would be to use absolute timing instead of relative (elapsed) timing. The reason is twofold:
    1. Absolute timing is dead easy to code and seems easier to manage as you introduce new and arbitrary events that might fall between preexisting events that you've created. Assuming you're not looking for ms accuracy, polling overhead won't be a big deal.
    2. With elapsed time, you run the risk of progressively falling behind schedule if events take longer to execute than you have anticipated or coded for.
    This is one of those "I'm sure it's been coded many times before" applications, but it seemed like fun, so I coded it up using a standard state machine. Mine uses a schedule-info array to define events and assumes that the elements of the array are ordered chronologically.
    Hope it helps,
    John
    Attachments:
    Scheduler.zip ‏33 KB

  • Internet wont work on iphone 6 at certain times of the day

    I have just recently bought a new iPhone 6 and during certain times of the day (usually (but not always) between 11AM-5PM) I have no internet connection from my home WiFi or from my carrier. Also sometimes this happens every other day or everyday. Whenever i open an app that uses the internet it either says no internet connection, crashes, or simply just doesn't do anything. I've tried disconnecting from my WiFi completely and using my carrier (the internet from that doesn't work either) and I've tried switching the WiFi in my settings on and off. if someone could please help me i would greatly appreciate it.

    try settings - general - reset - reset network settings, you will need to enter known wifi password again.

  • HT4113 Can you set a passcode to activate at certain times of the day, say at 930pm, and  turn off again the next morning?

    Can you set a passcode to activate at certain times of the day, say at 930pm, and  turn off again the next morning?

    No, sorry, you can't. The screen lock passcode is either on at all times or it's off.
    Regards.

  • Two problems, disconnecting and extremely slow internet at a certain time of the day.

    My first problem started to occur since the beginning of this year, after I've upgraded from 1MB/s to 3MB/s. EVERYDAY at 2:39 PM EST or sometime around there, my internet would disconnect (most common at 2:39). It would take some 5-20 minutes to reconnect by itself. I go to 192.168.1.1 and go to broadband connection and press disconnect, then reconnect to get myself back on asap. It would take me a few tries disconnecting and connecting to get the internet back up. I probably do disconnect during other times of the day, such as night time but I don't notice it as much because I am not using the computer at the time.
    My second problem is slow download speed at night. As I said, I have a 3000/667 kb/s connection. My internet connection speed is normal during the day time .. but when I ran a speed test during night time, I get around 333 kb/s download and 600 kb/s upload. So, my download speed drops significantly at night and my upload speed is normal.
    I am using a D90-327W15-06 modem and I am not using a wireless connection.
    Margin (dB) 14.5 11.0
    Line Attenuation (dB) 40.0 23.0
    Transmit Power (dBm) 18.4 11.9
    Don't know if that information helps ..
    P.S Sorry if this is a lot to read, I wanted it to be as much detailed as possible.

    #1 Is wireless in the router enabled?
    #2 If so, to question number one above: What level of wireless security is it set to ( WEP / WPA )?
    #3 Did you try connecting your modem to the NID?
    If not, please do that - and recheck those stats.
    If you do not what a NID is, see http://www.dslreports.com/faq/1317
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • Is there anyway to manage my contacts or an app so that I can temporarily block text messages at certain times of the day?

    Hi,
    I am wanting to block text messaging that I sometimes receive from clients after hours, and I want to know is there an app like there is for android phones that has lists that you can create so certain people can be sent an auto reply when they send you a message?
    I don't want to block the numbers completely just at weekends and/or after hours and I still want to be able to receive phone calls from those numbers as an option.
    I am on the Vodafone NZ network
    Thanks

    You can Remote Lock his iPad with Find My iPad using a computer at whatever time you like.
    http://support.apple.com/kb/PH2700
    Note: The iPad may be disabled if he tries the passcode too many times.

  • Internet LED turns Red at a certain time of the day

    I have a customer who last year would lose there internet connection like after 4:30pm each day. I was over there a couple days ago and saw it in action. I noticed that on the Actiontec GT704WG modem all the lights would start blinking and then the Internet LED would turn red with all other still green and then it would connect again for a minute and keep going through that cycle. Already did the reset of modem etc. Even happens when the Cat 5 cable is not plugged in. Could this be a power issue with the modem? Also, the ipconfig settings are fine when this is happening... Anyone have any ideas what the issue is? Thank You

    All of the lights blinking? Would this include the power lights or only the Ethernet and Wireless lights? If it's the lather, it sounds like the computer searching for a way to the Internet using broadcast packets. The DSL light if it's blinking would indicate a loss of sync, and this can turn the Internet light red. Anyhow, if you can clear up what exactly was blinking, we can continue.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • Prevent Data Manager Package to be startet at certain times of the day

    Hi
    We currently have an issue as described below.
    During month end closing SAP BW data is updated to BPC 3 times each day. This is done using a Data Package linke performing 8 steps in total. This DP Link works as expected. The problem is that while this is running users start other data manager packages that are based on the data from the data package link. This is an issue because the data is not correctly allocated before all 8 steps of the DP link has completed. This leads to very funny / Incomplete data and we would like to prevent this issue.
    The question is therefor! Can we implement some kind of logic that prevents users from starting other data manager packages when the DP link is running?
    /Chris

    Hi Chris,
    If you want to do the check for a DM which is running eg. a script via the default formular PC you can create copy of the PC and build in an extra step just after the start to run a custom program.
    You can set up the custom program eg. to check the table RSPCLOGCHAIN for dependent running PC or validate if the DM package can run dependent on some parameters set in a custom table. Eg. set the time range for when you are running the pakage link.
    You don't need much logic in the custom program to do the check.
    I don't see another or even standard way to do the check in BPC.
    Br
    Rasmus Larsen

  • DVR menu stalls out during certain times of the day

    Lately when I am trying to play or record a show from my DVR, I find that the menu stalls out and I am hitting the "OK" button to the point where my wrist hurts.  I have turned the box off for a while, but it doesn't help.  I find this only happens in the early morning or in the middle of the night.  I watch my shows at those times as I am feeding a newborn baby.  Anyone else have this problem?  Thanks. 

    the motorolla boxes are notorious for this... I have seen it with Verizon and Time Warner
    Have you tried simply unpluging the power from the box for a minute or so?
    If not, try that
    If need be, unplug the power to the box, unscrew the COAX from the box to the wall, and check the pin in the middle to make sure it is not bent or broken... Do the same at the wall jack, if applicable... If all is well, plug it all back up, turn it on and test it out
    IF it continues, call Technical Support at 1 888 553 1555
    Bob Robertson - Lighter Klepto - I steal lighters, not bandwith

  • I have to restore my phone from back up but in order to do it i had to update my software. now that my software is updated there isnt enough room on the phone to back up. is there a way to only restore certain things from the backup like contacts?

    i have to restore my phone from back up but in order to do it i had to update my software. now that my software is updated there isnt enough room on the phone to back up. is there a way to only restore certain things from the backup like contacts?

    Because it says it's incompatible when it can't be, I got hope. I get error messages all the time with my iPod and iPhone that it cannot sync and that 'this device is not capapble of connecting to iTunes' stuff. I literally forget that happened, plug it in again and it works, I later realize that iTunes made a mistake, they do that.

  • Can't open desktop - I get a window that says no application has been found to open the document desktop.

    Can't open desktop - I get a window that says no application has been found to open the document desktop.
    Any ideas?
    Thanks

    It may be that a "metadata attribute" called the "bundle bit" has somehow been set on the Desktop folder, such that the system treats it as a "package" rather than as a folder.
    To check for this, click on the Desktop, type command-I (Get Info), and look in the General section of the Info window under "Kind". It should say "Kind: Folder" - if it instead says "Kind:package," then I would proceed as follows:
    Download and run the utility File Matey. From its "Choose an Object" window, navigate to the Desktop folder and click Choose. In the next window, see if the box for "Has Bundle bit" is checked:
    If so, then uncheck it, and click Apply, then Save.

  • I am looking for an ipad app that will restrict game play during certain times, but will allow education and reading apps.  Is there such an app?

    I am looking for an ipad app that will restrict game play during certain times, but will allow education and reading apps.  Is there such an app?
    I want my kids to be able to take their ipads to school - restricting game play. 

    Not aware of such an app. Here's some generalparental controls info.
    How Do I Block Websites on My iPad?
    http://www.ehow.com/how_8716944_do-block-websites-ipad.html#ixzz2lh8910jd
    How To Set Parental Controls and Block Content on the iPhone, iPad, and iPod touch
    http://blog.laptopmag.com/how-to-set-parental-controls-and-block-content-on-the- iphone-ipad-and-ipod-touch
    How to block specific websites from being accessed with Safari for iPhone and iPad
    http://www.imore.com/how-block-specific-websites-being-accessed-safari-iphone-an d-ipad
    How To Setup Parental Controls On The iPad
    http://content.mobicip.com/content/how-setup-parental-controls-ipad
    ParentKit
    https://itunes.apple.com/us/app/parentkit/id600618138?ls=1&mt=8
    Parental TimeLock - Time limit for children
    https://itunes.apple.com/us/app/parental-timelock-time-limit/id689577280?ls=1&am p;mt
     Cheers, Tom

  • I recently purchased FaceTime from the Application Store. After approx. ±10 meg, the application resets and starts downloading again. I have tried to download it at different times of the day but with the same results. I have been in contact with Apple su

    I recently purchased FaceTime from the Application Store. After approx. ±10 meg, the application resets and starts downloading again. I have tried to download it at different times of the day but with the same results. I have been in contact with Apple support and have tried different options with the same result. I cannot download a new Version because in my Purchased List the applicaiton (FaceTime) is still there, and because I have halted it it tells me to resume. I can’t, because the same thing is going to happen. I have tried all the various troubleshooting tips supplied by my ISP and also Apple Support with no luck. I am currently working on a IMac OS 10.6.7. Has anybody got any ideas? Any suggestion would help. Thanks

    Amol Soni wrote:
    As I said, I tried everything what the manual says, but hard luck. I have taken an appointment for today, lets see what happens.
    Also there is no activity on unit when I use the remote. The unit is stuck on the first page itself where we have to choose the language. The unit seems to be fine to me but the real problem is remote does'nt have activity. The IR is not responding while pressing any of the button.
    Good luck with your appointment.
    Not much consolation but even new products can have issues and might need a trip to a store to return/replace.
    The reason i asked about the LED on the AppleTV is that occasionally it thinks it's paired with a specific remote and ignores others - the unpair keypress I described is quick and free.
    AC

Maybe you are looking for

  • My iPod nano 6th gen is not recognised by my computer or itunes, but still charges?

    My laptop recently came back from repairs and  wiped everything off of it, so I have had to reinstall everything again. The only way I have got my music is on my ipod, so I cant lose any of the music stored on the ipod. I have tried everything to con

  • How to transfer Lightroom settings  from one catalog to another?

    Lightroom 5. I have combined two catalogs into one "Master Catalog" per Julian Kosts tutorial ( http://tv.adobe.com/watch/adobe-evangelists-julieanne-kost/lr3-merging-individual-lightroo m-catalogs-into-a-master-catalog-/ ) without incident. However,

  • Watch Tv with apple 20 inch LCD monitor

    I have a 20 inch apple LCD monitor, I dont want to use it for my computer, instead I would want to use it to watch tv. How shd I do it or what shd I buy?

  • Oracle user.alert after unistalling 10g

    Hi, I'm getting following error after unistalling Oracle 10 . Platform : Sun solaris 2.8 Sparc Error Message : Dec 6 03:37:04 sunfire root: [ID 702911 user.alert] Waiting for filesystem containing /home/ora10g/product/10.1.0/db_1/bin/crsctl.

  • Where can I see Controller source code

    Hello all, My question might be stupid for some ADF gurus, however many people we found that R12 Pages have lots of code and there is not too much documentation about how to customise a controller. 1. I can see the *.class of my controller in the $JA