Archive for December, 2006

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.

Interested in high traffic RoR web sites?  Read how Robot Co-op’s setup handles 2.5 million hits per day and GreatSchools’ setup handles ~1 Million page views per day.

Happy Holidays, Merry Christmas and Happy Festivus.

Search