Also note that the behavior is different b/w java 1.3 and 1.4. Please see ObjectUtilsTest.testDateEquals() and turn on the // comments for an example.
gg > -----Original Message----- > From: Serge Knystautas [mailto:[EMAIL PROTECTED] > Sent: Monday, February 16, 2004 21:45 > To: Jakarta Commons Developers List > Subject: Re: DateUtils.equals(d1, d2) > > Todd V. Jonker wrote: > > Serge, I'm not sure that your proposed method will do what you want. > > > > You can't compare the results of java.util.Date.getTime() and > > java.sql.Timestamp.getTime() because the latter is only precise to the > > second, not the millisecond. Likewise, java.sql.Date.getTime() is only > > precise to the second. > > I understand java.sql.Timestamp is a bit screwy, but if you read the > javadoc for getTime() method, it says, "Returns the number of > milliseconds since January 1, 1970, 00:00:00 GMT represented by this > Timestamp object." So it should return milliseconds even if it is > structurally holding something different underneath. > > Regardless, it would help my situation... I'm using a db mapping layer > (hibernate) and it sets a java.util.Date object from the ResultSet. My > app code then prints to user, parses the data back, and I set the Date. > I want to check whether the value is changed, and I'm actually only > expecting resolution to date usually, sometimes to minute. > > > Just my two cents from painful experience... > > You may want to revisit the JDBC drivers that put you through this. The > ones I use now all do getTime() as milliseconds, and some of them used > to do just seconds as the class-level javadoc implies. Maybe this was > clarified in one of the more recent JVMs, dunno. > > -- > Serge Knystautas > President > Lokitech >> software . strategy . design >> http://www.lokitech.com > p. 301.656.5501 > e. [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]