在最后日期 freemarker 有 "and" 的日期

dates with "and" at the last date freemarker

我有一个用逗号分隔的日期列表。但我想要最后一个日期之前的 "and"。 我希望它看起来像这样:

日期,日期,日期(最后)日期。

我的代码:

<#list MySequence as x>${x}<#sep>,</#list>

不知道如何找到最后一个日期并将 "and" 添加到其中

谢谢

您可以根据当前指数来决定:

<#list MySequence as x>${x}<#sep><#if x?index == MySequence?size - 2> and <#else>, </#if></#list>

它不是很简洁...所以如果您经常这样做,请为它创建一个宏。