gpt4 book ai didi

java - 如何在 freemarker 中将日期转换为字符串?

转载 作者:行者123 更新时间:2023-12-02 12:02:05 24 4
gpt4 key购买 nike

我就是这样做的..

<#assign createdOn='${receipt.arPaymDate}'>
${createdOn?datetime("MMM dd yyyy HH:mm:ss 'GMT'Z")?date}

但我遇到了异常

Can't convert the date-like value to string because it isn't known if it's a date (no time part), time or date-time value. The blamed expression: ==> receipt.arPaymDate [in template "WEB-INF/ftl/receiptPdf.ftl" at line 22, column 47]

感谢各位

最佳答案

您可能需要首先初始化日期格式

<#setting date_format="dd-MM-yyyy">

<#assign createdOn='${receipt.arPaymDate}'>
${createdOn?datetime("MMM dd yyyy HH:mm:ss 'GMT'Z")?date}

另请参阅How to convert date in specific format in Freemarker template or javascript

关于java - 如何在 freemarker 中将日期转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47173906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com