grails在gsp视图中更改日期格式 [英] grails change Date format in gsp view

查看:165
本文介绍了grails在gsp视图中更改日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

p>

This is my code:

class MyDate {  
    Date date
}

MyDateController:

MyDateController:

....
def unixSeconds = params["date"].replaceAll("\"", "") as long  //params["date"]="1386157660"
Date date = new Date(unixSeconds*1000L)
myDateInstance = new MyDate(date:date)
....

gsp View :

gsp View:

${myDateInstance.date.format('yyyy-MM-dd HH:mm')}

我的格式是2013-12-04 12:47:40.0而不是2013-12-04 12:47

The format that I have is 2013-12-04 12:47:40.0 instead of 2013-12-04 12:47

推荐答案

Afaict,这不应该发生,我不能看到它是如何发生的......

Afaict, that shouldn't happen and I can't see how it is happening...

您确定这是产生您看到的输出的代码行吗?

Are you sure that's the line of code that's generating the output you're seeing?

您可以尝试Gra ils formatDate标签:

You could try the Grails formatDate tag in its place:

<g:formatDate format="yyyy-MM-dd HH:mm" date="${myDateInstance.date}"/>

这篇关于grails在gsp视图中更改日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆