Calendar hashCode() Method in Java with Examples Last Updated : 05 Jun, 2021 Comments Improve Suggest changes Like Article Like Report 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 hashCode() Method of Calendar class: Example 1: Java // Java code to illustrate // hashCode() method import java.util.*; public class Calendar_Demo { public static void main(String args[]) { // Creating a calendar object Calendar calndr = Calendar.getInstance(); // Displaying the current calendar System.out.println("The time on" + " Calendar shows: " + calndr.getTime()); // Getting the hash code int hash_code = calndr.hashCode(); System.out.println("The hash code " + "for this calendar is: " + hash_code); } } Output: The time on Calendar shows: Wed Feb 20 15:55:22 UTC 2019 The hash code for this calendar is: 194416203 Example 2: Java // Java code to illustrate // hashCode() method import java.util.*; public class Calendar_Demo { public static void main(String args[]) { // Creating a calendar Calendar calndr = new GregorianCalendar(2018, 6, 10); // Displaying the current calendar System.out.println("The time on" + " Calendar shows: " + calndr.getTime()); // Getting the hash code int hash_code = calndr.hashCode(); System.out.println("The hash code " + "for this calendar is: " + hash_code); } } Output: The time on Calendar shows: Tue Jul 10 00:00:00 UTC 2018 The hash code for this calendar is: -2123101761 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#hashCode-- Comment More infoAdvertise with us Next Article Calendar hashCode() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-Calendar +1 More Practice Tags : JavaMisc Similar Reads Date hashCode() method in Java with Examples The hashCode() method of Java Date class returns a value which is a hash code for this object. Syntax: public int hashCode() Parameters: The function does not accept any parameter. Return Value: It returns a hashCode value for this object. Exception: The function does not throws any exception. Progr 2 min read Calendar get() method in Java with Examples 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 2 min read ChronoLocalDate hashCode() method in Java with Examples The hashCode() method of ChronoLocalDate interface in Java is used to get the hashCode value of this ChronoLocalDate object in the integer form. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: The function returns a suitable hash code in the form of 1 min read Duration hashCode() method in Java with Examples The hashCode() method of Duration Class in java.time package is used to get the hashCode value of this duration. Syntax: public int hashCode() Parameters: This method do not accepts any parameter. Return Value: This method returns an int value which is the hashCode value of this duration. Below exam 1 min read DateFormat hashCode() method in Java with Examples The hashCode() Method of DateFormat class is used to return the hash code value of this DateFormat object. The hash code is of integer type. Syntax: public int hashCode() Parameters: The method does not take any parameters. Return Value: The method returns the hash code value of this DateFormat obje 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 ChronoPeriod hashCode() method in Java with Examples The hashCode() method of ChronoPeriod class in Java is used to get the generated hashCode for this period. Syntax: int hashCode() Parameters: This method does not accepts any parameter. Return Value: This method returns the hashCode generated for the given period. Below programs illustrate the hashC 2 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 Year hashCode() method in Java with Examples The hashCode() method of Year class in Java is used to get a suitable hash code for the current Year object. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: It returns a suitable integral hash code for the year object with which it is used. It never 1 min read Like