As most people are painfully aware of by now, the Java API for handling calendar dates (specifically the classes java.util.Date
and java.util.Calendar
) are a terrible mess.
Off the top of my head:
- Date is mutable
- Date represents a timestamp, not a date
- no easy way to convert between date components (day, month, year...) and Date
- Calendar is clunky to use, and tries to combine different calendar systems into one class
This post sums it up quite well, and JSR-310 also expains these problems.
Now my question is:
How did these classes make it into the Java SDK? Most of these problems seem fairly obvious (especially Date being mutable) and should have been easy to avoid. So how did it happen? Time pressure? Or are the problems obvious in retrospect only?
I realize this is not strictly a programming question, but I'd find it interesting to understand how API design could go so wrong. After all, mistakes are always a good learning opportunity (and I'm curious).