JSTL fmt:timeZone Formatting Tag

The JSTL <fmt:timeZone> Formatting Tag is used to specify the time zone.

Syntax: <fmt:timeZone value=”timeZone” />

fmt:timeZone tag attributes:

Attribute Description Required
value It specify the time zone to apply to the body. Yes

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
<html>
	<head>
		<title>fmt:timeZone JSTL formatting tag example</title>
	</head>
	<body>
	  <c:set var="currentDate" value="<%=new java.util.Date()%>"/>
	   <table>
	     <c:forEach var="timeZone" 
                       items="<%=java.util.TimeZone.getAvailableIDs()%>">
			  <tr>
			    <td>
			      <c:out value="${timeZone}" />
			    </td>
			    <td> 
			      <fmt:timeZone value="${timeZone}">
			        <fmt:formatDate 
                                   value="${currentDate}" type="both" />
			      </fmt:timeZone>
			    </td>
			  </tr>
		   </c:forEach>
		</table>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 50
 
Download this example.
 
Next Topic: JSTL fmt:setTimeZone Formatting Tag with example.
Previous Topic: JSTL fmt:setLocale Formatting Tag with example.

Related Topics:

JSTL fmt:formatNumber Formatting Tag with example.
JSTL fmt:parseNumber Formatting Tag with example.
JSTL fmt:formatDate Formatting Tag with example.
JSTL fmt:parseDate Formatting Tag with example.
JSTL fmt:bundle Formatting Tag with example.
JSTL fmt:setBundle Formatting Tag with example.
JSTL fmt:setLocale Formatting Tag with example.
JSTL fmt:timeZone Formatting Tag with example.
JSTL fmt:setTimeZone Formatting Tag with example.
JSTL fmt:requestEncoding Formatting Tag with example.