Setting system clock

It probably is a daft question - but please can anyone tell how to set
system date using the java api. By setting system date I mean the
computer's clock.
Thank you.

Java does not have a method for that. You need to access the os commands for that, either via JNI or the Runtime or ProcessBuilder classes. This will make the application non-portable.

Similar Messages

  • Howto set system clock with milliseconds precision

    Hi! I need to set the system clock with milliseconds precision. The Labwindows CVI SetSystemTime function use only seconds precision. How to get around the problem?
    Thanks in advice!
    Solved!
    Go to Solution.

    I talked too early,
    Actually I found that the SDK version of the  SetSytemTime function does accept milliseconds.
    However, its usage is a little different.
    You need to create an object of type SYSTEMTIME and set its members to the values you need.
    Then, call the SetSystemTime function (of the WinSDK) to set the clock.
    You need to add "windows.h" to the top of your include list.
    (see SDK help, there is a sample code available there) 
    Message Edited by ebalci on 01-04-2010 12:05 PM
    S. Eren BALCI
    www.aselsan.com.tr

  • Have a compaq nc6320 laptop the system clock is set to 6/3/9999

    why can't I seem to change the clock on this laptop couldnt find in bois where to set bois clock and tgried to change in windows 7 and it will not change

    I am not a Mac user, but have multiple versions and profiles of Firefox. I note you ask about Macs, but have system details showing as Windows 7.
    I can only speak from a PC perspective, but no doubt you can sort it out yourself. It is down to the OS which browser is the default, although firefox has the option to check and reset that at startup.
    No doubt if I delved into the registry I could find how it sets the default browser, but in practical terms what I do is allow the OS to set itself up.
    # Choose any other alternative browser such as IE, make that the default, and allow that to take effect.
    #Then deselect IE as default browser checking.
    #Now start up the chosen version of Firefox, use Firefox's options to set that as default browser. (Options -> advanced -> general system defaults )
    It works, although some applications may choose IE regardless.
    *You may be interested in http://kb.mozillazine.org/Default_browser
    With luck something similar may work on a Mac

  • How to set the system clock in win2000? in linux? (RH)

    hi There,
    I need to set the system time on a pure java application.
    what is the proper way to do so? (I can't find any system property which corresponds to the system clock).
    if it's platform dependent , then I need to do so on win2000 and on linux RH.
    thanks

    I don't know about Windows but on RedHat, I would use the date command. Check the man pages for date and look at the -s or --set options.  Do a Runtime.exec to execute that.
    Of course, doing the in Java is not the best option. If you are trying to synchronized clocks on Windows and Linux systems, I would use some freely available Network Time Protocol programs. RedHat has a free NTP daemon available as an RPM in the standard distribution. For Windows, theres a free program called "Net Time" that runs as a service. Both can act as clients and servers.

  • When I send emails w/Firefox (AOL) they are time stamped i hour earlier than my PC's system clock. My system is set to Eastern Time Zone

    When I send emails w/Firefox (AOL) they are time stamped i hour earlier than my PC's system clock. My system is set to Eastern Time Zone

    The cache is mentioned several times in the report.
    Go to ~/Library/Caches/com.apple.systempreferences
    Move the Cache.db file from the com.apple.systempreferences folder to the Trash.
    Restar your Mac.
    ~ (Tilde) character represents the Home folder.
    For Lion:   To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • Windriver erro "System clock has been set back"

    I am having a problem opening the First Windriver program this year.
    I always get the error:
    System clock has been set back
    Feature WR_workbench
    License Path c\windriver\license\zwrsLicense.lic;\\license\WRSLicense.lic 
    FLEXIm error: -88,-309
    For further information, refer to the FLEXIm End User Manual,
    available at www.macrovision.com.
    I also get a Different Workspace Version dialog box asking me to change or update the work space.
    I am using the Windows XP version on a Dell laptop computer that I have used for the last three years with the Windriver program that I updated each year. I have tried completely removing Windriver and National Instruments programs several times and rebooting all 2012 programs with no change in Windriver error.

    Hi eoconno1,
    If the Windriver program is related to the FIRST Robotics Competition then you will be able to get more help by posting in the FIRST community page at ni.com/first and searching/ asking in the NI FRC Community forum.
    This community forum is moderated by Applications Engineers specializing in support for FRC and FTC - they should be able to help you
    Milan

  • History wont update unless i set my system clock ahead 3 hours

    I have uninstalled and reinstalled firefox but nothing i do works. The history will only start working if i set my clock ahead 3 hours. Any way to fix that besides setting myself to a different time zone that's 3 hours behind me.

    Hi brotheryang17,
    I asked qa and there are some more steps to take to make sure that it is not an add on affecting the functionality of bookmarks. The two suspicious one are Ad Block or Ghostery, however it could be a combination as well.
    To run an experiment we can try two things: disabling each of the add ons one at a time to make sure that it is not an add on, or can try to create a new profile temporarily and add a bookmark with the time normally set.
    [[Troubleshoot Firefox issues using Safe Mode]] and [[Use the Profile Manager to create and remove Firefox profiles]]

  • Is Mail.app one of the "erratic" behavior apps with a reset system clock?

    I am hoping someone can help with a fine detail of mail.app (v2.1.3) behavior.
    I had an incident where an iMac sent out 200+ smtp hits a minute and was tossed of the network for presumed zombie spaming.
    I think I have actually tracked the problem to an unfortunate conjunction of circumstances that is actually innocent (if still annoying)
    Let me set up the story:
    1. This is a common use computer, so Mail is not configured (except that it is --I'll get to that in a moment) and
    2. Safari will invoke Mail when you click on an "email link"
    Mostly everyone just quits mail if they goof and click an email link.
    BUT some time ago at least one person invoked Mail and composed a message. This message, naturally, remained in the outbox ever since. That person learned that they can't send email that way, so ever since they just cmd-Q Mail.
    BUT Before this person learned, they walked through the mail-config and told mail to try hitting smtp.mac.com:"nonExistantUser".
    So that covers the lead-up. Two days ago, mail was invoked via a Safari link, BUT it wasn't quit, it was sent to the background.
    Where it undoubtedly tried to send the outbox repeatedly until it was kicked off the network.
    Here is what I don't understand:
    Under this scenario of a mis-configured .mac address, will mail repeatedly try and fail to smtp at the maximum possible rate?
    OR
    Is the one other factor I am about to describe responsible?
    The one other factor:
    The clock battery is dead and there was a power failure at 4am that day.
    The system clock reset to 1969.
    Of course, nobody reset it.
    Is mail.app one of the apps that the finder message warns "may behave erratically"?
    (a GROSS simplification) does it have a bit of code like:
    1 check time-of-last-send-mail-attempt
    check newest-item-in-outbox
    if newest-item more recent then last-send-attempt
    do send-mail and record time-of-last-send-mail-attempt
    and go to 1
    else wait X minutes and go to 1
    which, if the clock was mis-set to 1969 would always record a last-send-attempt prior to anything in the outbox and trigger a send loop.
    Does anyone know if either Mail is tenacious about sending to a bad .mac address, or gets ridiculous under this circumstance for bad-clock-set?
    Marc

    I am hoping someone can help with a fine detail of mail.app (v2.1.3) behavior.
    I had an incident where an iMac sent out 200+ smtp hits a minute and was tossed of the network for presumed zombie spaming.
    I think I have actually tracked the problem to an unfortunate conjunction of circumstances that is actually innocent (if still annoying)
    Let me set up the story:
    1. This is a common use computer, so Mail is not configured (except that it is --I'll get to that in a moment) and
    2. Safari will invoke Mail when you click on an "email link"
    Mostly everyone just quits mail if they goof and click an email link.
    BUT some time ago at least one person invoked Mail and composed a message. This message, naturally, remained in the outbox ever since. That person learned that they can't send email that way, so ever since they just cmd-Q Mail.
    BUT Before this person learned, they walked through the mail-config and told mail to try hitting smtp.mac.com:"nonExistantUser".
    So that covers the lead-up. Two days ago, mail was invoked via a Safari link, BUT it wasn't quit, it was sent to the background.
    Where it undoubtedly tried to send the outbox repeatedly until it was kicked off the network.
    Here is what I don't understand:
    Under this scenario of a mis-configured .mac address, will mail repeatedly try and fail to smtp at the maximum possible rate?
    OR
    Is the one other factor I am about to describe responsible?
    The one other factor:
    The clock battery is dead and there was a power failure at 4am that day.
    The system clock reset to 1969.
    Of course, nobody reset it.
    Is mail.app one of the apps that the finder message warns "may behave erratically"?
    (a GROSS simplification) does it have a bit of code like:
    1 check time-of-last-send-mail-attempt
    check newest-item-in-outbox
    if newest-item more recent then last-send-attempt
    do send-mail and record time-of-last-send-mail-attempt
    and go to 1
    else wait X minutes and go to 1
    which, if the clock was mis-set to 1969 would always record a last-send-attempt prior to anything in the outbox and trigger a send loop.
    Does anyone know if either Mail is tenacious about sending to a bad .mac address, or gets ridiculous under this circumstance for bad-clock-set?
    Marc

  • Can BootCamp beta be installed on Tiger by setting the clock back?

    Hello
    I have a MacBook, it is about one year old. I have been running BootCamp on with with XP Pro/SP2 since the day I got it, and it has always worked fine.
    Now, however, for a few reasons, I want to wipe my hard drive clean completely - set the partitions back to being one partition, format everything, install Tiger, install BootCamp, install XP, etc.
    I am concerned about BootCamp though, as the beta has expired and I don't intend on getting Leopard anytime soon.
    If I try to open the BootCamp assistant, it obviously says that it's expired. I've often heard that you can get around it by setting the system clock back to 2007. I did so, and I got the following common error message:
    "The startup disk cannot be partitioned or restored to a single partion..."
    I've read that this usually means that there's something wrong with the way your partitions are set up...but I have only two partitions, the OSX partition and the XP partition as the BootCamp Assistant itself set up a year ago. I've never had any trouble booting into Windows, and I've never had any problem with BootCamp before this. I don't know what could be causing this, but I'm thinking if I'm going to wipe the entire hard drive clean, I might as well just use disk utility to delete the XP partition and go from there.
    But I don't want to wipe my hard drive if I can't use BootCamp again afterwards, so my real question is this: If I wipe my hard drive completely, install OSX, and then
    1.Set the system clock back to 2007
    2.Install BootCamp Beta
    3.Run BootCamp Assistant to make the partitions, install XP
    4.After XP Installation, set the OSX clock back to its appropriate time
    WILL THAT WORK?
    I need a definitive answer to this, and it's no, is there any other way I can accomplish what I'm trying to do?

    Yes that should work, I have tried a similar thing in the past.
    See also http://support.apple.com/kb/HT1309
    "Boot Camp Beta: Removing a Windows partition after Boot Camp Beta has expired in Mac OS X 10.4"

  • Hardware clock and system clock don't match

    hello. i recently upgraded to kde 4.7, and i don't know if it's the culprit or not, but my system clock is now ahead of the hardware clock by the timezone offset.
    my timezone is Asia/Manila, which is UTC+8. so if the correct time is 00:00, the system time is 08:00.
    i dual boot with windows so the HARDWARECLOCK setting in /etc/rc.conf is set to localtime.
    interestingly, the commands "hwclock --show" and "date" both show PHT as the timezone, but with the aforementioned time skew. to illustrate:
    # hwclock --show
    Fri 05 Aug 2011 10:45:02 AM PHT -0.500309 seconds
    # date
    Fri Aug 5 18:45:02 PHT 2011
    running "hwclock --hctosys" fixes the problem while logged in, but restarting the computer reverts the problem. i could put a daemon that runs the command at startup, but i never needed to do that before and i'm not inclined to at the moment. i think this is just a misconfiguration somewhere.
    thanks for any help you could give.

    hello. it is
    hwclock from util-linux 2.19.1
    Using /dev interface to clock.
    Last drift adjustment done at 1312511647 seconds after 1969
    Last calibration done at 1304274137 seconds after 1969
    Hardware clock is on local time
    Assuming hardware clock is kept in local time.
    Waiting for clock tick...
    ...got clock tick
    Time read from Hardware Clock: 2011/08/05 12:08:46
    Hw clock time : 2011/08/05 12:08:46 = 1312517326 seconds since 1969
    Fri 05 Aug 2011 12:08:46 PM PHT -0.690104 seconds

  • Finder has got out of sync with system clock?

    For some reason, the system clock is reading the correct time, but the times indicated in Finder for "Date Modified" for every file or app are all wrong.
    For example, at 11:45PM (as indicated by the clock in the menu bar) I installed OnyX for the first time, but when I look at the newly-installed app itself in the Applications folder in Finder, in the Date Modified column it says "Today 11:23PM". Also, various different apps and files have identical Date Modified times - several have 12:12PM, several have 8:08AM, and many have 4:16PM.
    Two more confirmers that there's a problem - I just created a new folder at 12:35AM, and immediately went to look at it in the Finder - its Date Modified is "Today 12:00AM". And when I start up Plex, its own on-screen clock says "12:00AM" when the clock in the menu bar says 12:40AM.
    I've zapped the PRAM and forced a Spotlight reindex, but they've made no difference. Any suggestions?

    Is the correct Time Zone set for your region of use?
    Is the Time set to be coordinated with a network time server?
    These are two basic things that could go wrong. There may
    be others. I'm not sure at this moment what they may be.
    You may have to see if your use of OnyX has somehow
    changed the basic system settings; or maybe you did
    not use the section most likely in OnyX to be helpful.
    Or something else is acting up.
    (Looking into my Date Time panel now has me wondering,
    since I never look into there. It just works, usually!)
    Good luck & happy computing!

  • [SOLVED] System clock refuses to adopt my timezone

    (Running ArchLinux in VMWare)
    I'm trying to set my system clock to Europe/Lisbon unsuccessfully. I followed these steps:
    Step 1. (rc.conf)
    HARDWARECLOCK="UTC"
    TIMEZONE="Europe/Lisbon"
    Step 2. (localtime)
    $ rm /etc/localtime
    $ ln -sf /us/share/zoneinfo/Europe/Lisbon /etc/localtime
    Step 3. (reboot)
    Result:
    marfig@archway ~ $ date
    Fri Aug 6 15:27:26 WEST 2010
    marfig@archway ~ $ hwclock
    Fri 06 Aug 2010 03:27:31 PM WEST -0.000409 seconds
    Is there something wrong with /us/share/zoneinfo/Europe/Lisbon?
    Last edited by marfig (2010-08-06 14:49:17)

    marfig wrote:
    No. The time is correct. The timezone isn't. Why is it displaying Western time? (WEST)
    EDIT: gah! I'm so stupid. the simple fact I wrote this prompted me to search 'west timezone' in google. This Western European Time Summer Time. The timezone is correct and I'm a fool. So sorry for this useless thread.
    You should add this to the Try This thread called the "dumbest mistake you made"
    https://bbs.archlinux.org/viewtopic.php?id=11728
    Last edited by Inxsible (2010-08-06 14:51:18)

  • Stoping System Clock using Java code.

    Is it possible to do so if yes then some code idea for
    Stoping System Clock using Java code.
    [email protected]

    The system clock is controlled from the BIOS, and as such, I don't think even windoze can stop it, though it can be continually reset. I don't believe that Java provides a sufficiently low level of control to set the system clock, although you could use a native method to accomplish the task.
    Why would you want to do such a thing?

  • Java Thread.. System Clock gets slower..

    Hello All!
    I have never came accross such problem in my last 4 years of java development but right now its sucking my brain like any thing..
    Let me clerify what my application is doing.
    A node which is basically thread is executed and as it performs its job it is stopped by breaking the while loop like logic and then a method isRunnable() is called to calculate the time to run the thread again on the basis of pre-defined schedule (e.g. after 1 minute). so what i was doing in this method i was calling wait (sheduledMinutes*60*1000).
    There are multiple nodes which can be run in parallel. Problem occured when some nodes started immediately or after a time much shorter than the value defined in wait() method.
    So as an alternative way i decided to not rely on wait() and wrote my own implementaion i.e. i call wait(1000) in isRunnable() and the check if the current system time is less then the scheduled time. But it didn't work either.
    The problem revealed when i printed the valued of current time taken by the system and the scheduled one. The System clock gives the current time which is less than the actual System time shown on windows clock. I dont know why but it seems like as my threads continue to run the system clock gets slower or something and returns an old time. Hence nodes start immediately.
    Any solution to this problem would be highly appreciable.
    Regards,

    Well yeah u r right. I figured it out that it was just my threads running slowly. But the threads ran immediately there was another reason for that. My threads were waiting for the sheduled minutes to run again. In the mean while if i presed the stop button to stop the thread i was just setting the stop variable value to true. Which was basically the check in the while loop in run method. U can notice the thread still sleeping due to the call to wait method. And then if again mean while i press start button i called System.gc(). and then pass the current thread to new Thread like Threa t = new Thread(node); t.start();
    Now u can c another thread has been created but the last one was not collected by the garbage collector as it was still waiting and doing something ofcourse not dead. So now when new thread stops these was a possiblity of last thread ( one in waiting state) to run according to schedule and it make the current thread run immediately.
    I hope u can understand how difficult it was for me to figure this thing out :)
    But after 3/4 hours hair tearing i got the bug and then when i was stopping a thread i infact broke the waiting loop as well. Now the thread was dead and collected by garbage collector before new thread could start :)
    Hhhhhhhhhhhhhh sometimes programmign really sucks.
    Have fun. and thanx for ur concern..
    Regards

  • [SOLVED] System clock loses minutes at reboot

    For some reason, my system clock (as displayed by date) loses around five minutes every time I reboot. When I use date -s to set the time manually everything's fine until reboot when the clock will lose around five minutes again. Even if I put the clock forward 10 minutes it will lose 5 minutes again after reboot. This happens even if there is no connection to any other clock. No ntpd installed.
    How do I fix this (wthout ntpd)?
    Last edited by itektur (2014-09-20 14:45:52)

    Thank you for the quick reply. I set up systemd-timesyncd and it seems to work fine even after rebooting the system. Problem solved!

Maybe you are looking for