Groovy - setTime()
将此 Date 对象设置为表示 1970 年 1 月 1 日 00:00:00 GMT 之后的时间毫秒的时间点。
语法
public void setTime(long time)
参数
time − 毫秒数。
返回值
None
示例
以下是该方法的用法示例 −
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

