• Home
  • Big Data
  • Hadoop
  • Oozie
  • Hive
  • Tez
  • Scala
  • Archives
  • About

Gaurav Kohli

Gaurav Kohli

Monthly Archives: July 2013

Working with Joda-time and creating Extensions in Play

16 Tuesday Jul 2013

Posted by Gaurav in Play

≈ Leave a comment

Tags

Joda Datetime, Web Framework Play

I started using this new Web Framework Play few weeks back and came across the requirement to decide if to use java.util.Date or Joda-time API. I started with java.util.date as it was a simple tryout of writing a small CRUD application in Play, but eventually moved on to Joda-time when more functionality was needed out of the date fields ( I should have thought that from starting ).

But the moving from java.util.Date to Joda-time had some side effects, and I thought there should be some easy solutions to those. One of the problem was, Play has these cool Java extensions  format(pattern)  and format(pattern,language) which you can use with the Date object in the view templates directly.

${new Date(1275910970000).format('dd MMMM yyyy hh:mm:ss')}
07 June 2010 01:42:50

And when you use Joda-time you don’t have these extension, but the good part about Play is that it is equally easy to create new extensions. Just create a new class which extends play.templates.JavaExtensions and define a method and you are good to go.

So lets start with first using Joda-time API in your models and then creating some Java extensions for Joda-time

Continue reading →

Advertisement

Archives

  • December 2014 (1)
  • September 2014 (1)
  • August 2014 (1)
  • August 2013 (2)
  • July 2013 (1)

Tweet

  • RT @msisodia: The best appreciation that one can get ever! twitter.com/PriyankaJShukl… 2 years ago
  • RT @KushaKapila: time taken to ban @kunalkamra88 from several airlines: less than half a day time taken to arrest ABVP's Komal Sharma: sti… 3 years ago

Categories

  • Big Data (2)
  • Hadoop (3)
  • Jira (2)
  • Oozie (1)
  • Play (1)

Info

Amsterdam
Follow Gaurav Kohli on WordPress.com

Tweet

  • RT @msisodia: The best appreciation that one can get ever! twitter.com/PriyankaJShukl… 2 years ago

Categories

  • Big Data (2)
  • Hadoop (3)
  • Jira (2)
  • Oozie (1)
  • Play (1)

Archives

  • December 2014 (1)
  • September 2014 (1)
  • August 2014 (1)
  • August 2013 (2)
  • July 2013 (1)

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • Gaurav Kohli
    • Already have a WordPress.com account? Log in now.
    • Gaurav Kohli
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar