3 ms·
The Java calendar and date APIs are the worst for this and several other design flaws that come back to bite you. There's a reason why JodaTime (http://joda-tim
by king_jester 14y ago
The Java calendar and date APIs are the worst for this and several other design flaws that come back to bite you. There's a reason why JodaTime (http://joda-time.sourceforge.net/ http://joda-time.sourceforge.net/) is so popular.
- ajross 14y agoAll calendrics APIs will bite you. It's not a property of the API (though I agree Java's is bad) but of the problem domain. The gregorian calendar is simply a mess, and any API on that is just a facade on the mess. Never trust your calendar API. Never fool yourself into thinking you've found the right one. Always be very, very afraid when you find yourself doing arithmetic on a "date".
- sk5t 14y agoRight on... Jon Skeet offers a very fine article on the slipperyness of date-time arithmetic here (it's about .NET and Noda Time, but the same issues apply): http://noda-time.blogspot.com/2011/08/what-wrong-with-datetime-anyway.html http://noda-time.blogspot.com/2011/08/what-wrong-with-dateti...