Monday, September 29, 2014

JodaTime to rescue Java Calendar

Hello all, 
  • https://github.com/marcandreuf/LotteryGame
  • http://illegalargumentexception.blogspot.co.uk/2010/09/java-systemconsole-ides-and-testing.html

Once upon a time, I had to implement an exercice for a job application. It was required to implement a simple console lottery game.

Far many times I had heared that Java Calendar "sucks", however I thought to give it a try and well, if I write tests and they pass, it should be all fine, I thought. WRONG ASSUMPTION, big lesson learnt, Java Calenar really really really "F. Sucks". 

As usual the day I implemented the exercice all was working fine. Tests were always green, and the program worked as expected. And also as expected, all failed the day I had to explain the project on the technical interview. "WHF, what is going on here, it was all working in my computer". Of course, not the best sentence to say in a technical job interview, isn't it? I did not get the job, not because it did not work, but because my self-esteem when down and that is a big mistake in an interview process. 

Anyway, I said to myself that one day I will make this thing work properly and I did it after few months, when I got some spare time to invest in it. 

Here it is, the game and all J.Calendar has been replaced by the proper, nice and really powerful Joda Time library. Why has not been J.Calendar deleted from JAVA yet ?

I hope it helps. The project also has a very useful Java console abstraction library which makes it easier to develop simple java applications which needs to intercat via console. There is an issue wiht the Java Console as well. All J.C sucks in Java?

I hope you enjoy it and it works all perfectly fine for you in your next interveiw. 


Posted by Marc Andreu.

No comments: