<fmt:timeZone>
《fmt:timeZone》标记用于指定其正文中的所有标记将使用的时区。
属性 (Attribute)
《fmt:timeZone》标签具有以下属性 -
属性 | 描述 | 需要 | 默认 |
---|---|---|---|
Value | 适用于身体的时区 | Yes | None |
例子 (Example)
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
<html>
<head>
<title>JSTL fmt:timeZone Tag</title>
</head>
<body>
<c:set var = "now" value = "<% = new java.util.Date()%>" />
<table border = "1" width = "100%">
<tr>
<td width = "100%" colspan = "2" bgcolor = "#0000FF">
<p align = "center">
<b>
<font color = "#FFFFFF" size = "4">Formatting:
<fmt:formatDate value = "${now}" type = "both"
timeStyle = "long" dateStyle = "long" />
</font>
</b>
</p>
</td>
</tr>
<c:forEach var = "zone"
items = "<% = java.util.TimeZone.getAvailableIDs()%>">
<tr>
<td width = "51%">
<c:out value = "${zone}" />
</td>
<td width = "49%">
<fmt:timeZone value = "${zone}">
<fmt:formatDate value = "${now}" timeZone = "${zn}"
type = "both" />
</fmt:timeZone>
</td>
</tr>
</c:forEach>
</table>
</body>
</html>
上面的代码将生成以下结果 -
None
Formatting: 23 September 2010 15:09:09 GST | |
Etc/GMT+12 | 2010年9月22日23:09:09 |
Etc/GMT+11 | 2010年9月23日00:09:09 |