Java Date Time - Java Date.equals(Object obj)








Syntax

Date.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Date.equals(Object obj) method.

//ww w .ja v a 2s.c  o  m

import java.util.Date;

public class Main {

   public static void main(String[] args) {

      Date date = new Date();
      Date date2 = new Date();

      // Check if they are equal
      boolean check = date.equals(date2);

      // print the result
      System.out.println("Dates are equal:" + check);

   }
}

The code above generates the following result.