Java Calendar.internalGet(int field) method example

 Posted On  | Pooja Lakkihal 

In this java tutorial, You will learn how to get the value of the given calendar field. Java Calendar.internalGet(int field) method returns the value for the given calendar field.

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 - the given calendar field.

Returns

The value for the given calendar field.

Java Calendar internalGet(int field) example

  • Create CalendarApp instance which extends GregorianCalendar new CalendarApp();
  • calendar.getTime(); This will get the calendar time value.
  • calendar.internalGet(WEEK_OF_MONTH)); returns all values of calendar field.
package com.technicalkeeda;

import java.util.GregorianCalendar;

public class CalenderApp extends GregorianCalendar {

    public static void main(String[] args) {
        CalenderApp calendar = new CalenderApp();

        System.out.println("The current date is :- " + calendar.getTime());

        System.out.println("Week of month is :- " + calendar.internalGet(WEEK_OF_MONTH));

        System.out.println("Day of month is :- " + calendar.internalGet(DAY_OF_MONTH));

    }
}

output

The current date is :- Thu Jan 25 14:27:05 IST 2018
Week of month is :- 4
Day of month is :- 25


© technicalkeeda.com 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0364 seconds.