如何在 Grails 中更改 joda--time 默认日期时间格式 [英] How change joda--time default DateTime format in Grails

查看:27
本文介绍了如何在 Grails 中更改 joda--time 默认日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有 joda-time:1.3.1 和 joda-time-templates 插件的 Grails 2.0.3(groovy 1.8.6).一切正常,但我想更改日期和时间的显示格式.我怎样才能做到这一点?每个域都有脚手架,所以我无法访问任何视图来手动呈现它.

I am using Grails 2.0.3 (groovy 1.8.6) with joda-time:1.3.1 and joda-time-templates plugins. Everything works perfectly but I would like to change displayed format for date and time. How can I do that? Every domain is scaffolded so I do not have access to any view to render it manually.

我的域名

import org.joda.time.*
import org.joda.time.contrib.hibernate.*

    class Game {

        Team host
        Team guest
        String location
        DateTime date


        static mapping = {
            date type: PersistentDateTimeTZ, {
                column name: "date_timestamp"
                column name: "date_zone"
            }
        }
    }

渲染日期

Date 5/24/12 5:53 PM

我想得到它

Date 5 may 2012 17:53 PM 

有什么方法可以翻译月份名称

Is there any way to translate name of month

推荐答案

在 config.groovy 中定义

define this in config.groovy

jodatime {  format.org.joda.time.DateTime = "dd MMM YYYY HH:mm a" }

这应该照顾它.

这篇关于如何在 Grails 中更改 joda--time 默认日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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