Javatpoint Logo
Javatpoint Logo

Java Calendar get() Method

The get() method of Calender class returns the value of the parameter fields passed into it. Fields like DAY_OF_MONTH, MONTH, YEAR, WEEK, WEEK_OF_YEAR etc are passed as parameter to this method.

Syntax

Parameter

Any field of calendar is passed as parameter.

Returns

Return value of passed field as parameter in integer form.

Throws

ArrayIndexOutOfBoundsException

Example 1

Test it Now

Output:

Day of month is: 2
Month of year is: 7
and year is : 2018
Today is 2 Day  of 7 Month  of  the year 2018

Example 2

Test it Now

Output:

Hour is : 8
Minute is: 1
Second is1
Time : 8:1:1

Example 3

Test it Now

Output:

Date when objectt is created : Thu Aug 02 08:07:16 PDT 2018
date after using add method : Wed Jun 25 08:07:16 PDT 4036
HOUR : 8
MINUTE : 7
SECOND : 16



Help Others, Please Share

facebook twitter pinterest