Java Calendar.toString()

Syntax

Calendar.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use Calendar.toString() method.


/*  w w w  . j av  a  2 s . co m*/

import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

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

The code above generates the following result.