Groovy - getTime()



返回此 Date 对象表示的 1970 年 1 月 1 日 00:00:00 GMT 起的毫秒数。

语法

public long getTime()

参数

无。

返回值

此日期表示的 1970 年 1 月 1 日 00:00:00 GMT 起的毫秒数。

示例

以下是使用此方法的示例 −

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

运行以上程序后,将得到以下结果 −

1431288000000 
1431288000000 
1449769878348
groovy_dates_times.htm
广告
© . All rights reserved.