After playing with a Rails project that needed to do a lot of date maniupulation, I was shown another of the many “small” differences that make you so glad you are in Ruby-land.
With Ruby, and the time extensions that Rails adds to the Ruby time module, you get to do things like:
20.minutes.ago 20.hours.from_now now = Time.now now.at_beginning_of_year now.midnight now.last_month now.monday now.next_year now.tomorrow now.yesterday now.seconds_since_midnight
This is just a touch of what you can do.
The thought of doing a lot of this work in Java with the great java.util.Calendar and java.util.Date makes me cringe. I have a DateUtil that I use to do a lot of work, and there are other utils like JodaTime etc, but none compare in my opinion.
December 5th, 2005 at 9:59 am
You can do similar things with Joda in Java.
December 5th, 2005 at 10:54 am
Just be careful where/when you use such syntax sugar. 3.month.from_now for example equals 90 days from now not exactly 3 month. I agree that such little helpers are fun to use but when it comes to date manipulation the-hard-way (timezones, conversions, etc) you really wish for java.util.Calendar cause its actually good at it. Joda is also really good (even better actually).
December 5th, 2005 at 11:04 am
Hey, this is cool!
That’d be a worthy addition to Groovy since we can do the same cool tricks ;-)
You should add a JIRA ticket about that!
December 5th, 2005 at 12:24 pm
Is there a ruby ide that can tell you all these things while you are typing?
Now that I’ve gone eclipse, I cannot go back.
December 7th, 2005 at 5:34 am
See “Using the Ruby Development Tools plug-in for Eclipse” at http://www-128.ibm.com/developerworks/opensource/library/os-rubyeclipse/?ca=dgr-lnxw01Ruby4Eclipse
A URL for the plugin is http://sourceforge.net/projects/rubyeclipse.
April 21st, 2006 at 2:39 am
Java Calendar Component:
http://www.yaodownload.com/software-development/components-libraries/java-calendar/
December 17th, 2007 at 6:34 am
I am unable to find any feature that joda time has that java Date + java Calendar (+ a couple of Util classes easily obtainable) have. Personally, most of the complaints I see about java Date (and associated Calendar) are API related complaints (having to do with complexity (or perceived complexity) of the classes) and not with correctness.
I am unable to find in the internet a ** single bug ** in the java Date + Time implementations that justifies joda.
Now, what I AM worried about is just who are the people who implement Joda and why should I trust a rather complex date/Calendar logic to a bunch of volunteers?