獲取系統時間

2021-07-15 10:23:04 字數 753 閱讀 9758

一,如果只是單純的獲取系統時間,用******dateformat如下

******dateformat df = new ******dateformat("yyyy-mm-dd hh:mm:ss");

string systime=df.format(new date());

system.out.println(systime);

二,如果有 對年,月,日有修改操作等用calendar如下

calendar c = calendar.getinstance();//可以對每個時間域單獨修改

int year = c.get(calendar.year); 

int month = c.get(calendar.month)+1; 

int date = c.get(calendar.date); 

int hour = c.get(calendar.hour_of_day); 

int minute = c.get(calendar.minute); 

int second = c.get(calendar.second); 

system.out.println(year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);

string str = "2012-1-13 17:26:33";  //

date today = sdf.parse(str);  //轉化為date型別

獲取系統時間

include include include include include include sockaddr in標頭檔案 include include include int main int argc,char argv sock fd socket af inet,sock stream...

sql server獲取系統時間

sql server 2000用sql語句如何獲得當前系統時間 就是用getdate sql中的getdate 2008年01月08日 星期二 14 59 sql server 中乙個非常強大的日期格式化函式 select convert varchar 100 getdate 0 05 16 20...

ios獲取系統時間

簡單記錄一下ios裡面獲取系統時間的方法,以後有別的更詳細的功能再更新。nsstring date nsdateformatter formatter nsdateformatter alloc init formatter setdateformat yyyy mm dd 20hh mm ss d...