Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I set system date from java code?

803077Mar 3 2011 — edited Mar 3 2011
Hi. I need to set the system date from my application. It must works on Windows7 so the "cmd /C date" must be executed with Administrator privileges.
I tried do it that

Process p = rt.exec("runas /user:" + env.get("COMPUTERNAME") + "\\Administrator \"cmd /C date " + dateYYYYMMDD + "\"");

Then process ask me for password for administrator but it terminates befor i send it. exitCode() returns 1.

Have you some idea how can I do it?
Regards for you.

Comments

796440
At the very least, you need to read this and follow the advice it gives. That may or may not solve your problem, but it's a bare minimum.

http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 31 2011
Added on Mar 3 2011
1 comment
277 views