Friday the 13th with Joda Time

I’ve always wanted to try Joda Time and in this post I’d like to present some code that finds Friday the 13th dates. Wouldn’t it be interesting to know when the next Friday the 13th is or which year has got the most occurrences of this particular day?

The Eclipse project with the code for this post can be downloaded as tar.gz or zip. You can browse the code online here.

Continue reading →

Follow meta refresh with Commons HttpClient

Having to check the title tag from a lot of different websites I needed a tool that would follow HTTP redirects as well as redirects in meta refresh tags. As a fan of Commons HttpClient, I hacked together some code that does the work.

For the impatient: check out the code here.

Continue reading →

Iterating over the characters in a string

I was wondering what would be the fastest method to iterate over the characters in a string with Java. A small test implements the following things:

  • using an Iterable
  • toCharArray()
  • charAt()
  • calling charAt() on a CharSequence

You can download the Eclipse project as a tar or zip or browse the code online here; have a look at the StringIteratorTest class first.

Continue reading →

Caching with dynamic proxy classes

In my last post I used AspectJ to implement a cache that stored the returned result of methods with a special annotation (@Cachable). If you can’t use AspectJ you may want to use a dynamic proxy class: in this post I’ll present a solution for this.

You can download the Eclipse project as a tar or zip file or view the code online here.

Continue reading →