Hi all,

I have two strings containing dates.. I converted them into Date objects. now I want to compare them. I know that there is a very small difference between the two.. difference of a few seconds..... which i want to disregard.

if i use the equals method, my program displays that they are not equal..
but i want it to display that they are equal...

So, that means, i want to compare two Date Objects ( date and time ...in hours and minutes only) ....

How can i do that?
is there any other method available?

Please help!

"Proper" way: Use the GregorianCalendar class (and the methods it inherits from Calendar) to get the year/month/day/hour/minute as required so you can test for equality at whatever level of precision you need.

"Quick & dirty" way: get the time in millisecs for each date, subtract one from the other and look for a difference of less than 60,000 millisecs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.