【问题标题】:Grails export plugin set timezoneGrails 导出插件设置时区
【发布时间】:2015-07-01 15:28:57
【问题描述】:

我在 Excel 文件中导出包含日期的记录列表。

我在 Grail 2.3 中使用导出插件 1.6。 这是我使用的简单代码:

exportService.export("excel", new FileOutputStream(new File(pathFile + "BSE.xls")), bseRecordList, [:], [:])

文件已正确创建,但所有日期我都采用了 GMT 值而不是原始值。

我认为filed的参数中有一个设置我可以通过,但我不知道要写什么。

谢谢

【问题讨论】:

    标签: excel grails export grails-plugin


    【解决方案1】:

    您可以尝试使用格式化程序将日期字段转换为正确的目标类型(或至少按照下面的示例对其进行格式化)。

    def dateFormatter = {_,value -> value?.format('dd-MM-yyyy hh:mm:ss:SSS')}
    def formatters = [dateField:dateFormatter]
    exportService.export("excel", new FileOutputStream(new File(pathFile + "BSE.xls")), bseRecordList, [:], [:], formatters)
    

    【讨论】:

    • 我看了一下代码,可以通过格式化程序。它有帮助。谢谢@defectus
    猜你喜欢
    • 1970-01-01
    • 2016-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    相关资源
    最近更新 更多