Java.util.GregorianCalendar.hashCode() Method


Advertisements


Description

The java.util.GregorianCalendar.hashCode() method generates the hash code for this GregorianCalendar object.

Declaration

Following is the declaration for java.util.GregorianCalendar.hashCode() method

public int hashCode()

Parameters

NA

Return Value

This method returns a hash code value for this object.

Exception

NA

Example

The following example shows the usage of java.util.GregorianCalendar.hashCode() method.

Live Demo
package com.tutorialspoint;

import java.util.*;

public class GregorianCalendarDemo {
   public static void main(String[] args) {

      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // print a hashcode for this calendar
      System.out.println("Hash Code:" + cal.hashCode());
   }
}

Let us compile and run the above program, this will produce the following result −

Fri May 18 13:18:55 EEST 2012
Hash Code:1360560473

java_util_gregoriancalendar.htm

Advertisements