Java Date Time - 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.

// www.j av  a2  s  .  com

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.