Groovy setTime()方法

2018-12-29 15:06 更新

設(shè)置此Date對(duì)象以表示一個(gè)時(shí)間點(diǎn),即1970年1月1日00:00:00 GMT之后的時(shí)間毫秒。

句法

public void setTime(long time)

參數(shù)

time - 毫秒數(shù)。

返回值

沒(méi)有

例子

下面是一個(gè)使用這個(gè)方法的例子 -

class Example { 
   static void main(String[] args) { 
      Date olddate = new Date("05/11/2015"); 
      Date newdate = new Date("05/12/2015"); 
      Date latestdate = new Date();
		
      olddate.setTime(10000); 
      newdate.setTime(10000); 
      latestdate.setTime(10000); 
		
      System.out.println(olddate.toString()); 
      System.out.println(newdate.toString());
      System.out.println(latestdate.toString());  
   } 
}

當(dāng)我們運(yùn)行上面的程序,我們將得到以下結(jié)果 -

Thu Jan 01 04:00:10 GST 1970 
Thu Jan 01 04:00:10 GST 1970 
Thu Jan 01 04:00:10 GST 1970
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)