How to reset the Windows system date and time through Java ?
Java API for reset the Windows System date & time
--------------------------------------------
However you can execute any Windows command by using the Runtime class. So you should be able to invoke the Time and Date command. This piece of code will be used to update the date and time using java.
try
{
String newDate = "01-06-04";
String newTime = "8:30";
Runtime.getRuntime().exec("CMD /c \"DATE " + newDate + "\"");
Runtime.getRuntime().exec("CMD /c \"TIME " + newTime + "\"");
}
catch(Exception e){
// Unable to change the date and time
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment