play framework pretty print date

2019-06-28 03:50发布

I've been googling for a while but I just can't seem to figure out how to pretty print a java date in a template

my application.conf contains

date.format="yyyy-MM-dd hh:mm:ss"

and this is what I'm trying in my template

${(event.date).format('dd MMMM yyyy')}

The event member looks like

@Required
public Date date;

Any help would be appreciated, cheers!

1条回答
乱世女痞
2楼-- · 2019-06-28 03:57

You are using Play 1 formatting, which doesn't work in the Play 2 scala templates. You need to use the @ symbol in Play 2.

Try

 @event.date.format("dd MMMM yyyy")
查看更多
登录 后发表回答