<< Cross Site Scripting (XSS) and Denial of Service (DoS) using AJAX and other Technologies | Home | White Papers >>

java.util.Calendar and the before method

Came across this nice problem today:

The java.util.Calendar class provides a method "before(Object)" which is supposed to tell you if the calendar calling that method is before the given object. BUT, as stated in the javadocs [http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#before(java.lang.Object)] it only works if the passed object is a calendar itself. If its a java.util.Date object, then forget it, the method just returns false, even though you would expect the calendar to be able to compare its date with a Date object.

I can't quite figure out how come they don't just require a Calendar instead of an object. There is nothing in the code to give the reason. So, I just don't get it. But it's been like that for three years now, so I guess we just need to get used to it :-(

Tags :
Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!

Add a comment Send a TrackBack