I’ve just started using the Play framework, and I have some questions…
Some background info. I am using Play 2.0.4, with Ebean to store Entities.
My User Entity has 2 fields, one called created_on, and the other called updated_on. Both are java.util.Date.
My questions are,
what’s the best place to create the “created_on” variable?
I currently wrote it in the User model as
public Date created_on = new Date();
Is this the best place to put it? And I want to set the format as ‘dd-MM-yyyy’. I currently using
@Formats.DateTime(pattern="dd-MM-yyyy")
But it don’t seem to work, the created_on still print out as ‘Wed Jan 23 16:41:21 EST 2013’.
Also, I want to modify the updated_on field to the current time each time I does an update, where should I code it? and how should I do it?
Thank you very much
Although you can do your trick with
createdOnyou won’t be able to do the same withupdatedOnon update action – in such case probably fastest solution will be overwritingsave()andupdate(Object o)methods in your model(s) for doing the same task: