Date.toString() has the following syntax.
public String toString()
In the following code shows how to use Date.toString() method.
//from w ww . ja v a 2 s . co m import java.util.Date; public class Main { public static void main(String[] args) { // create a date Date date = new Date(); // print the string representation System.out.println("String : " + date.toString()); } }
The code above generates the following result.