GregorianCalendar hashCode() Method in Java Last Updated : 27 Jul, 2018 Comments Improve Suggest changes Like Article Like Report The java.util.GregorianCalendar.hashCode() is an in-built function in Java which generates hash code for this GregorianCalendar instance. Syntax: public int hashCode() Parameters: This function does not accept any parameters. Return Values: This function returns an integer value which represents the hash code for this GregorianCalendar instance. Examples: Input : Thu Jul 24 00:53:29 UTC 1997 Output : 2121703905 Input : Tue Jul 24 00:54:11 UTC 2018 Output : -909136554 Below programs illustrate the java.util.GregorianCalendar.hashCode() function: Program 1: Java // Java Program to illustrate hashCode() function // of GregorianCalendar class import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Create a new calendar GregorianCalendar c = (GregorianCalendar) GregorianCalendar.getInstance(); // Display the current date and time System.out.println("Current Date and Time : " + c.getTime()); // Display hashcode for this calendar System.out.println("Hash Code:" + c.hashCode()); } } Output: Current Date and Time : Fri Jul 27 11:43:16 UTC 2018 Hash Code:-612105832 Program 2: Java // Java Program to illustrate hashCode() function // of GregorianCalendar class import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Create a new calendar GregorianCalendar c = (GregorianCalendar) GregorianCalendar.getInstance(); // Display the current date and time System.out.println("Current Date and Time : " + c.getTime()); c.add((GregorianCalendar.YEAR), -12); System.out.println("Modified Date and Time : " + c.getTime()); // Display hashcode for this calendar System.out.println("Hash Code of the " + "modified date and time:" + c.hashCode()); } } Output: Current Date and Time : Fri Jul 27 11:43:18 UTC 2018 Modified Date and Time : Thu Jul 27 11:43:18 UTC 2006 Hash Code of the modified date and time:-1346149059 Reference: https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#hashCode() Comment More infoAdvertise with us Next Article BigInteger hashCode() Method in Java R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Java Java - util package Java-Functions Practice Tags : JavaMisc Similar Reads BigInteger hashCode() Method in Java The java.math.BigInteger.hashCode() method returns the hash code for this BigInteger. The hashcode is always the same if the object doesn't change. Hashcode is a unique code generated by the JVM at the time of object creation. We can use hashcode to perform some operation on hashing related algorith 2 min read BigInteger hashCode() Method in Java The java.math.BigInteger.hashCode() method returns the hash code for this BigInteger. The hashcode is always the same if the object doesn't change. Hashcode is a unique code generated by the JVM at the time of object creation. We can use hashcode to perform some operation on hashing related algorith 2 min read BigInteger hashCode() Method in Java The java.math.BigInteger.hashCode() method returns the hash code for this BigInteger. The hashcode is always the same if the object doesn't change. Hashcode is a unique code generated by the JVM at the time of object creation. We can use hashcode to perform some operation on hashing related algorith 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 CopyOnWriteArrayList hashCode() method in Java The hashCode() method of CopyOnWriteArrayList returns the hashCode value of the list. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the hashCode value of the list. Below programs illustrate the above function: Program 1: Jav 1 min read CopyOnWriteArrayList hashCode() method in Java The hashCode() method of CopyOnWriteArrayList returns the hashCode value of the list. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the hashCode value of the list. Below programs illustrate the above function: Program 1: Jav 1 min read Like