protocol7 archive
11 June 2007

Getting dates right this time

There’s tons of interesting discussions going on the the JSR-310 dev list right now. It’s the JSR for developing the new(er) date and time API for Java, based of Joda Time. The discussions are currently covering two important aspects, the basic design principles for the API and how to handle non-Gregorian calendars. The latter being something that the Calendar API failed at miserably. Not that it didn’t support it correctly, just that it did it in such an intrusive way that you quickly get annoyed with it.

The design principles this far looks well thought out:

  1. Immutable
  2. Fluent API
  3. Clear, explicit and expected

I think that setting basic principles like this for your API is a really good idea. As we learn more and more on what the winning principles are, it would be a topic for a book to collect them much like the GoF book. Personally, I think the XOM principles (also covered here) are the best general guideline currently available.

tags: Java