如何在JSTL中完整显示月份

How to display the Month in fully in JSTL

我正在使用 JSTL 来格式化 Java Date object 以像

这样的格式显示日期

September 29, 2015 11:28 AM

我尝试了以下方法,

<fmt:formatDate pattern="MMMMMMMM d,yyyy HH:mm a" value="${response.date}" />

我想知道这里需要多少 M。我的意思是我胡乱猜测了 8 M s。

JSTL <fmt:formatDate> 在幕后使用 java.text.SimpleDateFormat

因此,请阅读其javadoc如何使用模式语法。

Pattern letters are usually repeated, as their number determines the exact presentation:

  • Text: For formatting, if the number of pattern letters is 4 or more, the full form is used; otherwise a short or abbreviated form is used if available.

因此,MMMM 中的 4 个字母足以表示完整形式。