Friday, May 31, 2013

Pretty Date & Time representations in Java

Date and time representations in java has never been easy as both the Date as well as Calendar APIs have been poorly designed. In contrast, ActiveSupport gem in ruby allows for time to be declared constructively. For example, the time can either have arithmetic operations like 45.minutes + 2.months or can call constructive operations such as 1.year.from_now .
In java, this is not the case but thanks to PrettyTime library, this is possible from java as well. This is an easy-to use library which can be used easily without much of a fuss.
Apart from simple time substitutions, Pretty time can also pick up values within the String.

Consider the following example:
"I did this work three days ago"
"and I did that one week ago"

when processed by the following code,

List parse = new PrettyTimeParser().parse("I did this work three days ago");
parse.addAll(new PrettyTimeParser().parse("and I did that one week ago"));
for(Date dt : parse)
System.out.println("date obtained: "+dt);

results in :
date obtained: Tue May 28 18:46:00 IST 2013
date obtained: Fri May 24 18:46:00 IST 2013

There are various use cases that are still to be covered and working on them looks promising. I am giving this a try on a fork of the same project. I am hoping for some constructive feedback and a productive outcome from this exercise.

Thursday, May 23, 2013

Book Review: Learning Play Framework!

This is the book review of learning play framework2 by Andy Petrella.
The book focuses on scala based development on play framework. While the
book focuses on existing users of play, it gives a fast paced
introduction to scala and the level of complexity of the book is
slightly above the developer documentation, but not all the way high up
for serious deployment. There is a chapter for the uninitiated in scala,
which I feel is redundant as a section alone will do, given the
proliferation scala has made in java community. Also, it is easy to get
lost while following the samples, so I'd recommend that you keep the
sample questions handy while using this book.

The book starts with setup of play and a bit about its ecosystem, which is redundant. Next, it gives a fast-paced review of scala(it is not complete and I'd recommend the freely available 'scala for the impatient' book as a learning point). The book then demonstrates scala based templating mechanism in play and also plays with css configuration using LESS. It then delves into data management where data related views and routes are explained. This chapter also provides with the changes made in scala 2.1.1 and provides information about ebeans. The next couple of chapters  cover some of the exciting new features that were not present earlier and it deals with multipart content types as well as realtime client interactions through websocket.
A chat application is demonstrated and usage of Akka is shown to create non blocking multi-threaded access for clients, which is quite neat.

Interacting with web services is dealt next with a twitter integration into an existing web application is displayed. and the book caps off with chapters on testing and deployment. While testing is a chapter that I feel should have come before to further bring the TDD into development, the deployment chapter is totally updated. I was expecting to see the likes of jenkins and metrics tool in CI deployment, but there was various cloud vendors and their offerings that were waiting to be demonstrated.
Overall, this book is a great book to start with Play Framework2 and also does not disappoints with the ecosystem surrounding play.
Disclaimer: I received a copy of this book through Packt Publishing.
You can check out more about the book via

Wednesday, May 15, 2013

Relax, have fun and Play.. er Learn

Relax Play and Learn is the new mantra.. at least in learning Rails and related web tools used for development.
Maybe its just me, but over the past few days, I am increasingly finding newer and diverse forms of learning web development, especially using advanced frameworks like rails.
Some of these are directed at learning inter-spread with videos that users can learn at their own pace like the rails for zombies and others that focus on user provided content created by users themselves. Then, there are language specific courses like .
When I started learning rails, how much I wish that I had access to similar resources as these are godsend for learners; they serve the dual purpose of ease in learning as well as enjoyment for beginners.
As I write this post, I am also casually looking at various websites like that offer much higher quality screen casts than especially for beginners.
What is surprising is that other technologies do not have this type of support, but web application development centered around rails, scripting languages and HTML5, CSS3 and jQuery combined are increasingly finding this support. One can only hope that this type of open and user friendly learning increases its umbrella and allows more technologies into its fold in the near future.

So If you are a beginner or are considering using rails, my humble advice to you is to bookmark these and start when you have some extra/free time.

Friday, May 3, 2013

Book Review: Play framework cookbook

I had recently a chance to review the book, 'Play Framework Cookbook' by Alexander Reelsen through Packt Publishing.
Born out of inefficiencies in the workflow of conventional Enterprise Java development, Play framework has arisen and although has not reached great heights like its inspiration, Rails but has made name for itself and in turn has inspired various automation and rapid application development tools in java.
Out of a cookbook, you'd expect some power packed stuff backed by easily repeatable examples. This book does the same, even though the exercises are not that inspiring or usable but this is largely a framework issue.
The book starts with installation and runs the user through a newly created application. Next, controllers and features like authentication and rendering are discussed followed by modules. Although the book does not exhaustively lists modules, but provides fair amounts of module usage - being a cookbook, it can contain only a certain amount of module recepies at a time.
A nice feature that I'd like to point is the inclusion of creation of new modules, something which I didn't see before on other cookbooks.
Finally, the book caps off with production/deployment related chapter which is also highly appreciated as the other stuff is already there on documentation and other texts.
As java web development is scattered, on few places, even while following the book, I felt lost and could not comprehend the flow of the program. Also if the code was provided on github, things could have been easier, but that's just me.
As the book author states, It is for people with development experience and a bit of play framework knowledge/comfortableness, the book indeed does justice to its name.
Disclaimer: I received the copy of the book for review via Packt Publishing, if you feel like browsing this, head over to