Java Calendar.getInstance()

Syntax

Calendar.getInstance() has the following syntax.

public static Calendar getInstance()

Example

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


//from ww w. j  a v a  2  s . com


import java.util.Calendar;

public class Main {

   public static void main(String[] args) {
   
      // create a calendar    
      Calendar cal = Calendar.getInstance();

      // gets a calendar using the default time zone and locale.
      System.out.print("Date And Time Is: " + cal.getTime());
   }
}

The code above generates the following result.