Java設定系統時間

2021-04-17 12:30:03 字數 690 閱讀 1331

【無法實現的方法】

process   p   =   runtime.exec("date");   

outputstream   os   =   p.getoutputstream();   

os.write("2006-02-15/n");   

process   p   =   runtime.exec("time");   

outputstream   os   =   p.getoutputstream();   

os.write("15:04:50.32/n");

或者process   p   =   runtime.exec("date   2006-02-15");   

process   p   =   runtime.exec("time   15:04:50.32");

【可以實現的方法】

以上**設定不了系統時間的原因:因為

date

並非是乙個實際程序

..所以

process

沒辦法返回。。

如果真要那種設的話。你需要建乙個檔案。。用檔案來設時間。。因為檔案是乙個真正的程序。

try   

catch(exception   e)  

以上的方法還是有錯誤,有時可以實現有時卻實現不了,依舊不知道原因,望哪位高手指點,後給予更好的解決方法.

C 設定系統時間

在程式中有時需要系統時間準確,為了方便修改時間,做了個時間修改的,如下 using system using system.collections.generic using system.componentmodel using system.data using system.drawing u...

QT 設定系統時間

windows上實現 include include bool hstart sdate int year,int mon,int day linux上實現 qt 讀取和修改系統時間 qtime ct qtime currenttime 修改系統時間 change the system time q...

c API 設定系統時間

using system using system.collections.generic using system.linq using system.text using system.runtime.interopservices namespace 自動校正時間 api宣告 dllimpor...