difference between equals() and hashCode()

The equals() and hashCode() methods prove to be very important, when objects implementing these two methods are added to collections. If implemented incorrectly it might screwed up your life. equals() : This method checks if some other object passed to it as an argument is equal the object in which this method is invoked. It is easy to implement the … Read more

Compare 2 directories in windows

For Windows you can use this solution. Here’s the right way to do it, without the external downloads. It looks like a lot at first, but once you’ve done it, it’s very easy.It works in all Windows versions from 7 back to 95. For our example assume that you’re comparing two directories named ‘A’ and ‘B’. … Read more

Query comparing dates in SQL

Instead of ‘2013-04-12’ whose meaning depends on the local culture, use ‘20130412’ which is recognized as the culture invariant format. If you want to compare with December 4th, you should write ‘20131204’. If you want to compare with April 12th, you should write ‘20130412’. The article Write International Transact-SQL Statements from SQL Server’s documentation explains how to … Read more

How do I check for null values in JavaScript?

Javascript is very flexible with regards to checking for “null” values. I’m guessing you’re actually looking for empty strings, in which case this simpler code will work: Which will check for empty strings (“”), null, undefined, false and the numbers 0 and NaN Please note that if you are specifically checking for numbers it is a common mistake to miss 0 with this method, … Read more

Compare two dates with JavaScript

The Date object will do what you want – construct one for each date, then compare them using the >, <, <= or >=. The ==, !=, ===, and !== operators require you to use date.getTime() as in to be clear just checking for equality directly with the date objects won’t work I suggest you use drop-downs or some similar constrained form of date entry rather than text boxes, … Read more