Groovy - Dates & Times toString()


Advertisements

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

Useful Video Courses


Video

Groovy Fundamentals For Testers - Step By Step

Most Popular

52 Lectures 8 hours

Krishna Sakinala

Video

Groovy Programming Fundamentals for Java Developers

49 Lectures 2.5 hours

Packt Publishing

Advertisements