Java Calendar - internalGet() Method
The java.util.Calendar.internalGet() method returns the value of the given calendar field. This method does not involve normalization or validation of the field value.
Syntax
protected final int internalGet(int field)
Parameters
field |
Specify the given calendar field. |
Return Value
Returns the value for the given calendar field.
Exception
NA
Example:
In the example below, the java.util.Calendar.internalGet() method returns the value of the given calendar field.
import java.util.*; public class MyClass extends GregorianCalendar { public static void main(String[] args) { //creating a Calendar object with specified date MyClass Cal = new MyClass(); //printing the Calendar System.out.println("The Calendar is: " + Cal.getTime()); //printing the value for given fields System.out.println("Year is: " + Cal.internalGet(YEAR)); System.out.println("Month is: " + Cal.internalGet(MONTH)); } }
The output of the above code will be:
The Calendar is: Sun Sep 13 12:35:57 UTC 2020 Year is: 2020 Month is: 8
❮ Java.util - Calendar