Groovy - Dates & Times toString()



Converts this Date object to a String of the form

dow mon dd hh:mm:ss zzz yyyy

Syntax

public String toString() 

Parameters

None.

Return Value

A string representation of 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.toString()); 
      System.out.println(newdate.toString()); 
      System.out.println(latestdate.toString()); 
   } 
}

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

Mon May 11 00:00:00 GST 2015 
Mon May 11 00:00:00 GST 2015 
Thu Dec 10 21:46:18 GST 2015
groovy_dates_times.htm
Advertisements