Hi all, I would like to know if there's any way to set the system time using java, just as we can get the system time using . Please let me know how I can set the system time or atleast whether it is possible or not. Regards, Naresh
java gets the system time from the underlying operating system On most systems, setting time requires superuser privileges, so you cannot do it from vanilla Java.
To do this essentially will require you to #1. Create a native library to do setuid to become superuser #2. Call settimeofday (or equivalent system call) #3. Create a java wrapper to expose this as a java call
Doing this creates inherent security risks and breaks normal Java conventions and is not recommended.
What are you trying to do which requires you to set the system time from Java ?
<a href="http://www.auptyma.com" target="_blank" rel="nofollow">The Peak of Performance</a>