Archive for the ‘Java’ Category
February 22nd, 2007 at 3:38 am
JSR-310 recently accepted as a new JSR! What is JSR-310?
“This JSR will provide a new and improved date and time API for Java. The main goal is to build upon the lessons learned from the first two APIs (Date and Calendar) in Java SE, providing a more advanced and comprehensive model for date and time manipulation…..Currently Java SE has two separate date and time APIs – java.util.Date and java.util.Calendar. Both APIs are consistently described as difficult to use by Java developers on weblogs and forums. Notably, both use a zero-index for months, which is a cause of many bugs. Calendar has also suffered from many bugs and performance issues over the years, primarily due to storing its state in two different ways internally.”
Horray! It’s nice to know that I wasn’t the only one not happy with Java’s Date Time classes. I’ve swithced to Joda Time, but I would rather use someting that’s part of the standard package instead of a giant library to handle Dates.
I wish the Java guys will take some time to understand the .NET Framework’s handling of Dates and times and if they really want to make me happy, throw in some of of Ruby’s Humane interfaces.
December 25th, 2006 at 1:18 am
I’ve complained about the Java Date API classes before, it’s complicated,difficult to use and the calender class makes accessing methods clunky and well, verbose.
Last week I found Joda-Time, a replacement for the Java Date/Time classes. I played around with it for a week and found Joda-Time has great support for Time Zones and Time Periods which is super handy and easier to read than the JDK classes; it makes it easy to find some date plus/minus a time period, no more mucking around with the Calendar class or TimeZone classes.
Here’s a small example of what Joda-Time can do:
//JDK, adding 15 years to a date
Calendar rightNow = Calendar.getInstance();
rightNow.add(Calendar.YEAR, 15);
Date javaDate = rightNow.getTime();
System.out.println(javaDate.toString());
//Joda Time, adding 15 years to a date
DateTime jodaDate = new DateTime().plusYears(15);
System.out.println(jodaDate.toString());
//Joda Time, changing timezone
DateTime newDate = jodaDate.withZone(DateTimeZone.forID(”US/Eastern”));
System.out.println(newDate.toString());
Play around with Joda-Time and decide for yourself.
November 6th, 2006 at 2:44 am
I really wish Sun would simplify the classes related to dates in the Java Library. The java.util.date and java.util.*calendar* classes are a mess, very verbose and cumbersome to use. This ONJava article helps but it’s just a reminder of how much easier dates are to play with in .NET