Java.util.Date.toString() Method

Advertisements


Description

The java.util.Date.toString() method Converts this Date to a String of the form: dow mon dd hh:mm:ss zzz yyyy

Declaration

Following is the declaration for java.util.Date.toString() method

public String toString()

Parameters

  • NA

Return Value

The method returns a string representation of this date.

Exception

  • NA

Example

The following example shows the usage of java.util.Date.toString() method.

package com.tutorialspoint;

import java.util.*;

public class DateDemo {

   public static void main(String[] args) {

      // create a date
      Date date = new Date(92, 1, 10);

      // print the string representation
      System.out.println("String :  " + date.toString());
   }
}

Let us compile and run the above program, this will produce the following result:

String:  Thu Jan 10 02:00:00 EET 1992



Advertisements
Advertisements