百"/>  百">

Home  >  Article  >  Web Front-end  >  Detailed explanation of JSTL data formatting examples

Detailed explanation of JSTL data formatting examples

零下一度
零下一度Original
2017-07-27 16:59:361294browse

Date represents

<fmt:formatDate value="${DATE1}" pattern="yyyy-MM-dd hh:mm:ss" type="date" dateStyle="long" /> 
<fmt:formatDate value="${DATE2}" type="date" pattern="yyyy-MM-dd"/>

Percent, thousandth represents

<fmt:formatNumber value="${DoubleVALUE}" type="number" pattern="0.00‰" />    0.01 ‰
<fmt:formatNumber    value="${DoubleVALUE}"   type="number" pattern="0.00%" />    0.20 %

Other digital representation

<fmt:formatNumber value="123456.7891" pattern="#,#00.0#"/> -- 123,456.79
<fmt:formatNumber value="123456.7" pattern="#,#00.0#"/> -- 123,456.7
<fmt:formatNumber value="123456.7" pattern="#,#00.00#"/> -- 123,456.70
<fmt:formatNumber value="12" type="percent" /> -- 1,200%type 可以是currency、 number、 和percent。

Currency representation

===1
<fmt:setLocale value="ch_CH" />
<fmt:formatNumber value="${data}" type="currency" />
==2
<fmt:formatNumber value="${doubleValue}" type="number" pattern="¥0.00" />

The output format of fmt:formatDate

<fmt:formatDate value="${isoDate}" type="both"/>2004-5-31 23:59:59
<fmt:formatDate value="${date}" type="date"/>2004-4-1
<fmt:formatDate value="${isoDate}" type="time"/>23:59:59
<fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>04-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>2004年5月31日
<fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>2004年5月31日 星期一
<fmt:formatDate value="${isoDate}" type="time" timeStyle="default"/>23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>下午11:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="medium"/>23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="long"/>下午11时59分59秒
<fmt:formatDate value="${isoDate}" type="time" timeStyle="full"/>下午11时59分59秒 CDT
<fmt:formatDate value="${date}" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/>星期四, 四月 1, 2004 13:30:00 -0600
<fmt:formatDate value="${isoDate}" type="both" pattern="d MMM yy, h:m:s a zzzz/>31 五月 04, 11:59:59 下午 中央夏令时

Format mode:
d A certain day in the month. Single-digit dates have no leading zeros.​
dd A certain day in the month. Single-digit dates have a leading zero.​
ddd The abbreviated name of a day of the week, defined in AbbreviatedDayNames.​
dddd The full name of a day of the week, as defined in DayNames .​
M Month number. Single-digit months have no leading zeros.​
MM month number. Single-digit months have a leading zero.​
MMM The abbreviated name of the month, defined in AbbreviatedMonthNames.​
MMMM The full name of the month, as defined in MonthNames .​ ​
y ​ The year without the epoch. If the year without the epoch is less than 10, the year without leading zeros is displayed.​
yy Year without epoch. If the year without the epoch is less than 10, the year with leading zeros is displayed.​
yyyy ​ A four-digit year including the epoch.​
gg Period or era. If the date being formatted does not have an associated period or epoch string, the pattern is ignored.​
h ​ The hour in the 12-hour clock. Single-digit hours have no leading zeros.​
hh Hour in 12-hour format. Single-digit hours have leading zeros.​
H Hour in 24-hour format. Single-digit hours have no leading zeros.​
HH Hour in 24-hour format. Single-digit hours have leading zeros.                                                                                                                                                                                                                                     · Single-digit minutes have no leading zeros.​
mm minutes. Single-digit minutes have a leading zero.​
s seconds. Single-digit seconds have no leading zeros.​
ss seconds. Single-digit seconds have a leading zero.

<fmt:formatDate value="${xx}" pattern="dd/MM/yyyy HH:mm aa"/>和
<fmt:formatDate value="${xx}" pattern="dd/MM/yyyy hh:mm aa"/>  对于0点显示的结果不一样


The above is the detailed content of Detailed explanation of JSTL data formatting examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn