About time for JSR 310

2

Apparently, Java date and time is getting an overhaul with JSR 310 to be initially based on JodaTime. Check out the announcement from Stephen Colebourne.

I’ve spent far more time than I care to think about wrangling with and being frustrated by the various java.util.{Date, Calendar}, java.sql.{Date, Time, Timestamp}, etc. I’m overjoyed to see a path for change that’s long overdue. I’ve spent a lot of time working with (and inside) JDBC drivers and the java.sql classes are horribly frustrating. All of these extend java.util.Date and provide their own hacked abstraction (Date ignores time, Time ignores date, and Timestamp adds precision). However, they don’t fully hide their roots – for example, they don’t override the equals() method and it is possible to construct instances of all of these that are the same (for the abstraction they’re presenting) but do not compare equals. Working with the java.sql.Timestamp nanos is always a hack-fest. Classes like the date formatters can’t access them so you can’t properly format Timestamp with the JDK’s own utilities.

This is just the tip of the iceberg, of course. Hallelujah for JSR 310!!

Comments

2 Responses to “About time for JSR 310”

Trackbacks

Check out what others are saying about this post...
  1. [...] one more thing: Java’s Date classes and the Calendar class are crap. (Alex is right.) They’re mutable, painful to use, and buggy. The JBoss DNA SPI created its own DateTime [...]