Groovy Groundhogs, revisited

For those people in the U.S. who are concerned that this morning Punxsutawney Phil, the Seer of Seers, Prognosticator of Prognosticators, emerged, reluctantly, but alertly, and stated in groundhog-ese, “I definitely see a shadow”, let me allay your fears using Groovy:

Calendar cal = Calendar.instance

cal.set(year:2014, month:Calendar.FEBRUARY, date:2)
def groundhogDay = cal.time

cal.set(year:2014, month:Calendar.MARCH, date:20)
def firstDayOfSpring = cal.time

int days = firstDayOfSpring - groundhogDay
println """There are $days days between Groundhog Day and the first Day of Spring.
That's ${(int) (days/7)} weeks and ${days % 7} days.

The result of that script is:

There are 46 days between Groundhog Day and the first Day of Spring.
That's 6 weeks and 4 days.

In other words, “six more weeks of winter” is a good thing, because otherwise we’d have to wait an extra four days.

A few notes are in order:

  • Here is the official Groundhog Day site.
  • According to the Wikipedia page, Phil has been predicting the weather since 1887. His accuracy rate is only about 39%, however.
  • Some kind of Groundhog Day celebration has been recorded since as far back as 1841. It bears similarities to the pagan festival of Imbolc, among others.
  • If you don’t like using the Calendar class (and who does?), the Groovy JDK also adds a parse method directly to java.util.Date:
    Date groundhogDay = Date.parse('MM/dd/yyyy', '02/02/2014')
    Date firstDayOfSpring = Date.parse('MM/dd/yyyy', '03/20/2014')

    and the rest is the same.

  • The Vernal Equinox this year occurs on March 20, 2014, at 1:57pm EDT.
  • I considered posting this blog entry over and over as some sort of weak tribute to the movie, but at least I spared you that. 🙂

There’s more, but I have to go get ready for our Super Bowl party, where the announcers have been talking about the weather all week and will no doubt be disappointed that the temperature will be in the 40s (Fahrenheit).

About Ken Kousen
I am a Java Champion and the author of the books "Modern Java Recipes" (O'Reilly Media), "Gradle Recipes for Android" (O'Reilly Media), and "Making Java Groovy" (Manning), as well as over a dozen video courses at Safari Books Online. I'm a regular member of the No Fluff, Just Stuff conference tour and have given talks all over the world. Through my company, Kousen IT, Inc, I've taught training courses to and worked with thousands of developers.

2 Responses to Groovy Groundhogs, revisited

  1. Approved by the FDA. The problem is alcohol makes your skin glow and
    make it soft and polished. Here’s the thing
    though: for people like me with sensitive skin cannot use traditional acne scar treatments can help to decrease the inflammation and redness.

  2. Bacterial infections may cause a condition where the face gets red with bumps or pustules on the chin, cheeks and forehead.
    Hope acne treatments you have found the cleanser of your dreams as your skin pigmentation, skin redness and dryness.

    You should always consider your special skin care needs.
    Your acne treatments friends and spouse will probably
    notice that your skin condition. However you aren’t sure for you wish to use a foundation primer to the skin. Occasionally you
    may want to try using an aspirin mask every time
    you wear make-up.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: