設置此 Date 對象以表示一個時間點,即 1970 年 1 月 1 日 00:00:00 GMT 之後的時間毫秒。
用法
public void setTime(long time)
參數
time- 毫秒數。
返回值
空
示例
以下是使用此方法的示例 -
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());
}
}
當我們運行上述程序時,我們將得到以下結果 -
Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970
相關用法
- Groovy sin()用法及代碼示例
- Groovy subString()用法及代碼示例
- Groovy subList()用法及代碼示例
- Groovy split()用法及代碼示例
- Groovy sqrt()用法及代碼示例
- Groovy matches()用法及代碼示例
- Groovy after()用法及代碼示例
- Groovy padRight()用法及代碼示例
- Groovy contains()用法及代碼示例
- Groovy exp()用法及代碼示例
- Groovy equals()用法及代碼示例
- Groovy before()用法及代碼示例
- Groovy pow()用法及代碼示例
注:本文由純淨天空篩選整理自 Groovy - setTime()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。