Java GregorianCalendar from() Method



Description

The Java GregorianCalendar getCalendarType() method returns the "gregory" as the calendar type.

Declaration

Following is the declaration for java.util.GregorianCalendar.getCalendarType() method

public String getCalendarType()

Parameters

NA

Return Value

This method returns "gregory" as calendar type.

Exception

NA

Getting Calendar Type from a Current Dated GregorianCalendar Instance Example

The following example shows the usage of Java Calendar getCalendarType() method. We're creating a Calendar instance of current date and then printed its type using getCalendarType() method invocation.

package com.tutorialspoint;

import java.util.GregorianCalendar;

public class GregorianCalendarDemo {
   public static void main(String[] args) {

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar)GregorianCalendar.getInstance();

      // print the caleander type
      System.out.println(cal.getCalendarType());
   }
}

Output

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

gregory
java_util_gregoriancalendar.htm
Advertisements