This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See In my opinion, this is much easier to read. Note that Date also overloads the equals() method, so you don't even need to convert the Date to a String first. In other words, you can reduce this method to a single line of code:
Notice that I am just comparing each member field for equality here. Also, this is a much more general solution because it only relies on the fact that the classes involved override the equals() method themselves. In my mind, this makes more sense when you are implementing a custom equals() method than it does to rely on classes overriding toString(). On the other hand, if I were implementing a custom toString() method, I would rely on the toString() method from other classes.
I hope this helps. And welcome to the Ranch!
[ August 27, 2005: Message edited by: Layne Lund ] [ August 27, 2005: Message edited by: Layne Lund ]