November 2010 Archives

♻ Ode to Joda-Time

| No TrackBacks

After using a really well-designed API for a while, I feel obliged to thank its creators. Thank you, Joda-Time.

To paraphrase a colleague: Joda-Time seems way over-designed at first glance, but once you start using it in an application, you realize everything is there for a purpose.

Essentially, Joda-Time replaces Java’s clunky Date and Calendar-based way of manipulating times. Everything is immutable (though you can use mutable variants, if you want), and every method you need is there when you content assist. Often, there are different ways to get what you need, too:

DateTime now = new DateTime();
DateTime yesterday = now.minusDays(1);
DateTime anotherYesterday = now.minus(Days.ONE);

One of the great features is how the API separates the notions of time between two DateTimes (an Interval) and our normal notion of calendar time (a Period). (There’s also another notion of time as a fixed number of milliseconds called a Duration.) The names are confusing at first, but I swear they make sense.

DateTime adamsEpoch = 
    new DateTime(1986, 7, 14, 22, 26, 0, 0, 
DateTime now = new DateTime();
Interval adamsLife = 
    new Interval(adamsEpoch, now);
DateTime y2k = new DateTime(2000, 1, 1, 0, 0, 0, 0);
Interval twentiethCentury = 
    new Interval(y2k.withYear(1900), y2k);
Interval adamInTwentiethCentury = adamsLife.overlap(y2k);
DateTime twentyFifthBirthday =; // Using the Years Period

Joda-Time also lets you format your dates in pretty much any conceivable way and handles all sorts of time zone and calendar quirks gracefully, but I won’t get into that here.

The short version: Joda-Time saves everyone time.

After learning that Utah, of all states, was the deciding ratifier of the 21st Amendment (ending Prohibition by repealing the 18th), I had to learn more. How could this predominantly teetotaling state go and do this? How insanely… principled!

Thanks to Google Books, it didn’t take long for me to find the proceedings of the state ratifications (the 21st Amendment is the only amendment to be ratified by “state conventions,” rather than state legislatures). The Utah vote was unanimous among its delegates, and I enjoyed the dialogue between Delegate Sam Thurman and the convention’s president, who both realized the significance of the moment (and that Pennsylvania had ratified only a few hours earlier!):

The speech immediately prior to the vote seemed to reflect the sentiment of the time:

The average citizen is willing to pay a reasonable premium to patronize a legitimate dealer, either private or public [Ed. note: Utah chose public dealers], but it is perfectly obvious that if legal beer, legal wine and legal spirits are made expensive through excessive taxation, such beverages, all of them, without exception, will again be the stock-in-trade of the bootlegger and racketeer. Prohibition created a millennium for crime, by providing high profits and small penalties. No, if we are wise in this country, repeal will create a Waterloo for crime, by providing small profit and heavy penalties.

♻ Say Biz

| No TrackBacks

Most of us know Biz Markie as the creator of the venerable “Just a Friend,” but did you know he’s also a badass DJ? And a collector of not only records, but pretty much everything: shoes, kung-fu movies, …and Barbies?

Biz Markie is more of a legend to me now, due to a collection of stories about the man entitled The Biz Never Sleeps (the name of his second album). It’s not updated anymore, but who cares? It’s full of gems like:

Biz and I are shootin’ the shit on the phone one day and his other line rings. he says hold on and clicks over. Then he comes back on and says “yo thes, you gotta be real real quiet when I click over again aight? don’t say anything aight? just sit there and listen aight?” Then he clicks over again and now I’m on three way calling with him and some girl and he starts macking her up, but making little record jokes while he’s doing it. I’m trying not to laugh but can’t believe what I’m hearing. he’s on the phone with her for like 45 minutes and convinces her to come through and “rub his back”. Dude is the mack like that. She hangs up and he starts whilin’ like See Thes?!! That’s how you do it??!! Right there!

I need to see this man live.

P.S.: Biz, notorious for sampling, appropriated one of the greatest refrains in music in his “Things Get a Little Easier:”