Java.util.Calendar.internalGet() Method

Advertisements


Description

The java.util.Calendar.internalGet(int field) method returns the value of the given calendar field. This does not involve validation or normalization.

Declaration

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

protected final int internalGet(int field)

Parameters

  • field -- the given calendar field.

Return Value

This method returns the value for the given calendar field.

Exception

  • NA

Example

The following example shows the usage of java.util.Calendar.internalGet() method.

package com.tutorialspoint;

import java.util.*;

public class CalendarDemo extends GregorianCalendar {

   public static void main(String[] args) {

      // create a new calendar
      CalendarDemo cal = new CalendarDemo();

      // print the current date
      System.out.println("The current date is : " + cal.getTime());

      // use internal get to get the year
      System.out.println("Year is : " + cal.internalGet(YEAR));

      // use internal get to get the month
      System.out.println("Month is : " + cal.internalGet(MONTH));

   }
}

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

The current date is : Thu Jun 21 15:38:25 EEST 2012
Year is : 2012
Month is : 5



Advertisements
Advertisements