Java Calendar get() MethodThe 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. SyntaxParameterAny field of calendar is passed as parameter. ReturnsReturn value of passed field as parameter in integer form. ThrowsArrayIndexOutOfBoundsException Example 1Test it NowOutput: 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 2Test it NowOutput: Hour is : 8 Minute is: 1 Second is1 Time : 8:1:1 Example 3Test it NowOutput: 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
Next TopicJava Calendar Class
|