Freemarker / Velocity - 日期操作 [英] Freemarker/Velocity - date manipulation
问题描述
我对这两个模板引擎有一个相当简单的问题。
我正在尝试创建一个未来/过去的日期,从现在开始的固定时间,例如18个月前或明天。
I have a fairly simple question about these 2 templating engines.
I'm trying to make a future/past date, a fixed time from now, e.g. 18 months ago, or tomorrow.
我知道可以在速度/自由标记模板中使用java日期对象(类似 $ date.add(2,-18)
),但我想用 DateTool 或freemarker core。
I know that it is possible to do this with a java date object inside a velocity/freemarker template (something like $date.add(2,-18)
), but I would like to do this with DateTool or freemarker core.
这是我看到的东西纯粹是表示性的(只是想想你在飞行预订表格中看到的默认日期),所以我看不出为什么模板引擎不应该这样做的原因。
This is something that I see as purely presentational (just think at the default dates you see in flight booking forms), so I can't see any reason why a templating engine shouldn't be able to do this.
虽然可以吗?如果是这样,怎么做?
Is it possible though? If so, how?
推荐答案
在Velocity Tools中没有这样的方法。
In Velocity Tools there is no such method.
这篇关于Freemarker / Velocity - 日期操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!