Java.util.Calendar.toString() Method

Advertisements


Description

The java.util.Calendar.toString() method returns a string representation of the calendar.

Declaration

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

public String toString()

Parameters

  • NA

Return Value

This method does not return a value.

Exception

  • NA

Example

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

package com.tutorialspoint;

import java.util.*;

public class CalendarDemo {

   public static void main(String[] args) {

      // create a calendar
      Calendar cal = Calendar.getInstance();
      
      // return a string representation of this calendar.
      System.out.println(cal.getTime().toString());
   }
}

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

Wed May 02 20:48:32 EEST 2012



Advertisements
Advertisements