Groovy – getTime()

  • Post author:
  • Post category:Groovy
  • Post comments:1 Comment
Date object

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Syntax

public long getTime()

Parameters

None.

Return Value

The number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

Example

Following is an example of the usage of this method −

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()); 
   } 
}	  

When we run the above program, we will get the following result −

1431288000000 
1431288000000 
1449769878348

Previous Page:-Click Here

This Post Has One Comment

Leave a Reply