commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serge Knystautas <>
Subject DateUtils.equals(d1, d2)
Date Fri, 13 Feb 2004 23:12:37 GMT
There was a bugzilla issue opened about this, and a brief discussion 
about such, but I wanted to move it to the list for better visibility.

Basically if you have 2 date objects (e.g., java.util.Date and 
java.sql.Timestamp), ObjectUtils.equals() will return that they are not 
equal even if they represent the same point in time.

Unless someone objects, I was going to add DateUtils.equals(Date d1, 
Date d2) and the equality check will be what's returned from each date's 
getTime().  Just as an example:

long now = System.currentTimeMillis();
Date date = new java.util.Date(now);
Date ts = new java.sql.Timestamp(now);

ObjectUtils.equals(date, ts) = false; (as of 2.1)
DateUtils.equals(date, ts) = true;

Anyone have a different idea or think this is a bad idea?

Serge Knystautas
Lokitech >>> software . strategy . design >>
p. 301.656.5501

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message