根据日期在 FreeMarker 中获取一年中的第几周

问题描述 投票:0回答:1

我需要根据字符串日期获取一年中的当前周。 例如 07.03.2023 => 2023 年第 10 周

文档我找到了很多帮手,但一年中的那一周都没有。

<#assign aDate = theDate?date>
<!-- All kind of day of the week, month, year etc, -->
${aDate?string["EEE, MMM d, ''yy"]}
<!-- How to get the week of the year? -->

我如何仅使用 FreeMarker 模板获取日期中的星期几。 感谢您的帮助。

date freemarker week-number
1个回答
0
投票

FreeMarker 使用 Java 简单日期格式模式 来格式化日期。您可以使用

w
模式来获取“一年中的一周”。所以你可以简单地做:

Current week number: ${.now?string['w']}
© www.soinside.com 2019 - 2024. All rights reserved.