a.getDate() obviously returns java.sql.Timestamp
java.sql.Timestamp has a different equality method than java.uti.Date , which is basically
return obj instanceof Date && getTime() == ((Date) obj).getTime();
Timestamp however more complex and requires the target to also be Timestamp .
if (ts instanceof Timestamp) { return this.equals((Timestamp)ts);
You are probably using Hibernate or something similar, which is saved by java.util.Date as a Timestamp .
source share