Java Utility Library

Java Date - hashCode() Method



The java.util.Date.hashCode() method returns a hash code value for this object.

Syntax

public int hashCode()

Parameters

No parameter is required.

Return Value

Returns a hash code value for this object.

Exception

NA

Example:

In the example below, the java.util.Date.hashCode() method returns a hash code value for the given Date.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Date
    Date Dt = new Date();

    //print hashcode of the Date
    System.out.print("Hash Code of the Date is: ");
    System.out.print(Dt.hashCode());
  }
}

The output of the above code will be:

Hash Code of the Date is: 1269235895

❮ Java.util - Date