下面的android代码只是随手写的,没有验证过能不能用,仅供参考。
大体的思路就是执行这样一个命令/system/bin/date -s "2012-06-03 13:12:00"
因为不同的系统date文件可能不一定有或者不一定存放在这个位置,得自己找到正确的位置自己调整。
另外date命令的格式也不尽相同,印象中android下好像是这样的吧,可以在调试串口的命令终端中先试验是否正确。
try
{
Process dateexe;
dateexe= Runtime.getRuntime().exec("/system/bin/date");
String cmd = " -s \"2012-06-03 13:12:00\" ";
dateexe.getOutputStream().write(cmd.getBytes());
if ((dateexe.waitFor() != 0) {
throw ; }
}
不保证能用哦,如果你最后试成功了,不妨把最终的结果也贴上来看看。