java.util.Date equals() doesn't seem to work as expected

后端 未结 3 476
醉话见心
醉话见心 2020-12-18 20:52

Problem

I have a Map, and a list of objects from the database with an effectiveDate property, and I want to check to see

3条回答
  •  天涯浪人
    2020-12-18 21:43

    A Date object returned from a database would probably be a java.sql.Timestamp, which cannot be equal to a java.util.Date object. I'd just take the long returned from getTime(), and use that as a key in your HashMap.

提交回复
热议问题