play framework pretty print date

青春壹個敷衍的年華 提交于 2019-12-23 15:29:24

问题


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:


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")


来源:https://stackoverflow.com/questions/15697184/play-framework-pretty-print-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!