Home » Java programming language

Java Calendar internalGet() Method with Example

Calendar Class internalGet() method: Here, we are going to learn about the internalGet() method of Calendar Class with its syntax and example.
Submitted by Preeti Jain, on February 01, 2020

Calendar Class internalGet() method

  • internalGet() method is available in java.util package.
  • internalGet() method is used to get the value of the given field(fi) of this Calendar & it is non-validated value.
  • internalGet() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
  • internalGet() method does not throw an exception at the time of returning the value.

Syntax:

    protected final int internalGet(int fi);

Parameter(s):

  • int fi – represents the calendar field.

Return value:

The return type of the method is int, it returns the value of the given parameter fi (calendar field).

Example:

// Java Program to demonstrate the example of
// int internalGet(int fi) method of Calendar

import java.util.*;

public class InternalGet extends GregorianCalendar {
    public static void main(String args[]) {
        // Instantiating a Calendar object
        InternalGet ca = new InternalGet();

        // By using internalGet() method is to
        // get the value of the Calendar
        int year = ca.internalGet(YEAR);
        int month = ca.internalGet(MONTH);
        int days = ca.internalGet(DATE);

        // Display hash code of this Calendar
        System.out.println("ca.internalGet(YEAR): " + year);
        System.out.println("ca.internalGet(MONTH): " + month);
        System.out.println("ca.internalGet(DATE): " + days);
    }
}

Output

ca.internalGet(YEAR): 2020
ca.internalGet(MONTH): 0
ca.internalGet(DATE): 27



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.