" var="" scope=""/>"> " var="" scope=""/>" />
Easy Tutorial

<fmt:setTimeZone> Tag

JSP Standard Tag Library

The <fmt:setTimeZone> tag is used to copy a time zone object to the specified scope.

Syntax

&lt;fmt:setTimeZone value="<string>" var="<string>" scope="<string>"/>

Attributes

The <fmt:setTimeZone> tag has the following attributes:

Attribute Description Required Default Value
value Time zone Yes None
var Variable name to store the new time zone No Replace default
scope Scope of the variable No Page

Example Demonstration

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ 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:setTimeZone Tag</title>
</head>
<body>
&lt;c:set var="now" value="<%=new java.util.Date()%>" />
<p>Current Time Zone Time: <fmt:formatDate value="${now}" 
             type="both" timeStyle="long" dateStyle="long" /></p>
<p>Change to GMT-8 Time Zone:</p>
&lt;fmt:setTimeZone value="GMT-8" />
<p>Date in Changed Zone: <fmt:formatDate value="${now}" 
             type="both" timeStyle="long" dateStyle="long" /></p>
</body>
</html>

Output:

Current Time Zone Time: June 26, 2016 11:34:05 AM

Change to GMT-8 Time Zone:

Date in Changed Zone: June 25, 2016 7:34:05 PM

JSP Standard Tag Library