Skip to main content

Yesterday Never Tomorrows

Posted by editor on September 18, 2008 at 7:28 AM PDT

Will JSR 310 finally bring sense to Java dates and times?

Time-keeping is one of those problem domains that's nice and easy until it isn't. I think I got my first taste of this when I was working the overnight shift at CNN during a change from daylight savings time to standard time. Because you set your clocks back at 2AM, we had two 2AM shows that night: one for 2AM Eastern Daylight Time, followed immediately by one for 2AM Eastern Standard Time. This also made scheduling nice and tricky for all involved, and everyone on the overnight shift picked up an hour of overtime, because we had to work 9 hours instead of 8 to get from 11PM to 7AM the next day.

Would your scheduling application have handled the change correctly? Or would you have just added 8 hours to 11PM and thereby miss the extra "fall back" hour?

Date and time management in Java has been a mixed bag from the beginning. The handling of absolute times is simple enough: since Java 1.0, System.currentTimeMillis() has returned the number of milliseconds elapsed since January 1, 1970, at midnight GMT. It's in translating concept that to dates and times and intervals thereof that things fall apart. java.util.Date tried to represent these instants as human-readable dates and times in Java 1.0... and most of its methods got deprecated in Java 1.1. For a decade, we've muddled through with Calendar, its weird API for calculating intervals for concepts like "two days from now", and other hassles.

Maybe the third time will be the charm.
In our Feature Article, Jesse Farnham takes a look at
JSR 310: A New Java Date/Time API.

JSR 310 is an
API for time- and calendar-related calculations that has been
proposed for Java SE 7. The API aims to replace the two existing
classes that form Java's current date and time API,
java.util.Date and java.util.Calendar,
while still providing backwards-compatible access to these older
APIs. The JSR is currently in development, and a "">tentative
is available for the API.

The JSR 310 date/time API attempts to improve upon Java's
current date/time API by providing increased performance and
ease of use. For example, the Java Calendar class
stores a date simultaneously as a millisecond offset from a
standard epoch, and as a set of calendar fields (e.g., day of week,
day of month, and month of year). This double representation causes
the calendar fields to be recomputed at unexpected times, resulting
in unpredictable performance characteristics. In contrast, JSR 310
classes store date/time representations only as a nanosecond offset
from the same standard epoch used by Date and
Calendar; calendar fields such as day of month are
only computed when needed and are not used for internal
representation of dates.

This is another JSR that's on track for inclusion for Java 7, so jump in if you want an advanced look at what you'll hopefully be using this time next year.

In Java Today,
the SDN continues a tutorial in its Core Java Technologies Tech Tips series with Exchanging Data With XML and JAXB, Part 2. "In this tip, you'll learn how JAXB's binding customization features can facilitate XML processing for the recipient of data as well as for the sender. Binding customization offers a level of control over the characteristics of the Java classes generated by the JAXB schema compiler. This allows you to work with an object model that makes sense for your business domain even when processing XML instance documents based on a schema that is not of your own design."

Making use of MarkMail's tools for searching mailing lists, The Aquarium notes Growth in OpenESB mail traffic and wonders if it might be a leading indicator of interest in the project. "The OpenESB mailing lists
are showing a significant growth in traffic this month.
It is just the 17th and the
Combined Traffic
so far is 1384 (up from 765 for all of August),
while the
USERS Traffic
is 419 (up from 190 for all of August)."

No one writing Java applications should be without an understanding of how to fix things when they go wrong. Diagnosing performance problems can be difficult; sometimes even knowing where to start is hard. In a podcast from TheServerSide, Java Performance Tooling, Dr. Holly Cummins will introduce a number of tools for identifying and fixing common Java performance problems.

Today's Weblogs begins with John Vieten showing off a technique for Full-duplex communication with the Grizzly Framework. "I recently joined the Grizzly Project as a committer. One of the first things I did is write a Tutorial on How-to write a custom protocol with the help of Grizzly. [...] So I thought it should be very easy to come up with a Grizzly Demo version of Rex Young's Port Implementation. And here it is."

Felipe Gaucho brings up a security concern in Compiling your own byte array Trojan with JAXB 2.0. "Do you mind about the quality of the code generated by automatic tools? I do care, specially when a warning of Findbugs makes sense against code generated by JAXB 2.0."

Finally, Cay Horstmann reports that he's been
Teaching Software Engineering with BlackBerry. "One of the best aspects of my job as computer science professor is that I keep learning new stuff. This semester, I am teaching a software engineering class. Cinequest, the organization that puts on the annual San Jose film festival, approached the CS department, asking for help with their mobile initiative. We jumped at the chance, and now my students are hard at work designing and prototyping a BlackBerry application for festival attendees."

In today's Forums, pauldb finds it unacceptable that Web Start applications cannot be launched offline. "In an earlier post I reported that web start applications could not be launched offline from the command line. I reported this bug here: However, the situation is even worse than that. Without a network connection, in my experience at least, they cannot be launched offline from the Java Cache Viewer either. (I hadn't realised this earlier because I still had the network connection). If you are developing web start applications, please vote for this bug. For me, this is a showstopper. I have customers who need to be able to launch the application offline."

chihiro_saito discusses Blu-Ray Java development and testing in
Re: An Havi Component Like JList. "bdj.jar that's been discussed in this forum is meant for your xlet compilation, and not for runtime. You can't just take the jar file out of a pc player (nero, powerdvd etc), stick it into a java runtime environment in some IDE like eclipse or netbeans, and expect it to work. You essentially need some sort of an emulator or a bd-j runtime environment to test HAVi APIs on a PC. We've been recommending commercial BD PC players as an alternative to a bd-j emulator. Another popular choice seems to be XletView, which is an MHP runtime emulator. MHP impl won't have org.bluray APIs, obviously, but HAVi will be there (at least as a partial impl, as described in this thread)."

Finally, Clive Brettingham-Moore explains WSDL port management in
Re: How to override endpoint address of service from client code. "You don't need to dynamically add ports if you have specified WSDL, either using Service.create(URL,QName) or a generated Service class (instances of gererated service are just like the two arg create; the default constructor simply uses a default WSDL URL & QName). As you have noticed Service.create(QName) is really only useful for Dispatch, but the two argument method (and subclasses) will work out the ports from the WSDL (WSDL is also needed for the getPort methods to work)."

Current and upcoming Java

Registered users can submit event listings for the href=""> Events Page using our href="">events submission form.
All submissions go through an editorial review before being posted to the

Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the href=""> Archive.

Will JSR 310 finally bring sense to Java dates and times?


And here I though you had some insight into a new 007 title. :p