Calendar get() method in Java with Examples Last Updated : 14 Feb, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The get(int field_value) method of Calendar class is used to return the value of the given calendar field in the parameter. Syntax: public int get(int field) Parameters: The method takes one parameter field_value of integer type and refers to the calendar whose value is needed to be returned. Return Value: The method returns the value of the passed field. Below programs illustrate the working of get() Method of Calendar class: Example 1: Java // Java Code to illustrate // get() Method import java.util.*; public class CalendarClassDemo extends GregorianCalendar { public static void main(String args[]) { // Creating a calendar Calendar calndr = Calendar.getInstance(); // Getting the value of all // the calendar date fields System.out.println("The given calendar's" + " year is: " + calndr.get(Calendar.YEAR)); System.out.println("The given calendar's" + " month is: " + calndr.get(Calendar.MONTH)); System.out.println("The given calendar's" + " day is: " + calndr.get(Calendar.DATE)); } } Output: The given calendar's year is: 2019 The given calendar's month is: 1 The given calendar's day is: 13 Example 2: Java // Java Code to illustrate // get() Method import java.util.*; public class CalendarClassDemo extends GregorianCalendar { public static void main(String args[]) { // Creating a calendar object Calendar calndr = new GregorianCalendar(2018, 9, 2); // Getting the value of all // the calendar date fields System.out.println("The given calendar's" + " year is: " + calndr.get(Calendar.YEAR)); System.out.println("The given calendar's" + " month is: " + calndr.get(Calendar.MONTH)); System.out.println("The given calendar's" + " day is: " + calndr.get(Calendar.DATE)); } } Output: The given calendar's year is: 2019 The given calendar's month is: 9 The given calendar's day is: 2 Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#get(int) Comment More infoAdvertise with us Next Article Calendar get() method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java-Functions Java-Calendar Practice Tags : JavaMisc Similar Reads Calendar getMaximum() method in Java with Examples The getMaximum(int calndr_field) method in Calendar class is used to return the maximum value for the given calendar field(int calndr_field) of this Calendar instance. Syntax: public abstract int getMaximum(int calndr_field) Parameters: The method takes one parameter calndr_field that refers to the 2 min read Calendar getInstance() Method in Java with Examples The getInstance() method in Calendar class is used to get a calendar using the current time zone and locale of the system. Syntax: public static Calendar getInstance() Parameters: The method does not take any parameters. Return Value: The method returns the calendar. Below program illustrates the wo 1 min read Calendar add() Method in Java with Examples The add() method of Calendar class present inside is used to add or subtract from the given calendar field(int field), a specific amount of time(int amt), based on the calendar's rules. Syntax: public abstract void add(int field, int amt) Parameters: The method takes two parameters: The field of the 3 min read Calendar set() Method in Java with Examples The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field. Syntax: public void set(int calndr_field, int new_val) Parameters: The method takes two parameters: calndr_field: This is 2 min read Calendar hashCode() Method in Java with Examples The hashCode() method in Calendar class is used to return the hash code for this Calendar Object.Syntax: public int hashCode() Parameters: The method does not take any parameters.Return Value: The method returns the hash code value for this calendar object..Below programs illustrate the working of h 2 min read Like