<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on"><b><i><;fmt:timeZone>;</i> tag</b> is used to specify the time zone. It&#8217;s scope is limited to its body, it parses the actions that are nested into its body.</p>
<p> The <i><b><;fmt:timeZone>;</b></i> tag is used to specify the time zone information for any date formatting in its body. This tag is different from <;fmt:setTimeZone>; in that, <;fmt:setTimeZone>; is used to set the default time zone. However, the <;fmt:timeZone>; tag sets the time zone for the tags within its body. Rest of the JSP page uses the time zone set by the <;fmt:setTimeZone>; or the default time zone.</p>
<p> <b>Syntax-</b><br />
<i><;fmt:timeZone value=&#8221;<;string>;&#8221;/>;</i></p>
<p> <b>Attributes of <i><;fmt:timeZone>;</i> tag:</b></p>
<p> <b>value : </b>This is a required attribute that specifies the name of a time zone/time zone IDs supported by java or an instance of the java.util.TimeZone.</p>
<p> The following JSP code displays the current date using the default time zone and displays current date using the GMT-8 time zone. The GMT-8 time zone is set using the <;fmt:timeZone>; tag. Notice that we are displaying the date within the body of the <;fmt:timeZone>; tag.</p>
<pre class="highlight" name="code"><;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>;
 <;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>;
 <;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>;
<;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
 "http://www.w3.org/TR/html4/loose.dtd">;
<;html>;
 <;head>;
 <;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">;
 <;title>;&;lt;fmt:timeZone&;gt; Demo<;/title>;
 <;/head>;
 <;body>;
 <;h1>;&;lt;fmt:timeZone&;gt; Demo<;/h1>;
 <;c:set var="today" value="<;%=new java.util.Date()%>;" />;
 <;c:set var="timeZone" value="GMT-8"/>;
 Date in the current time zone:
 <;strong>;<;fmt:formatDate value="${today}" type="both" />;<;/strong>;
 <;br/>;
 Date in the GMT-8 time zone (nested in &;lt;fmt:timeZone&;gt; tag):
 <;fmt:timeZone value="${timeZone}">;
 <;strong>;
 <;fmt:formatDate value="${today}" timeZone="${timeZone}" type="both" />;
 <;/strong>;
 <;/fmt:timeZone>;
 <;/body>;
<;/html>;
</pre>
<p>
<b>Output&#8211;</b></p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="http://50.87.249.200/~dineshon/wp-content/uploads/2013/10/333-2.png" /></div>
<p>
<b>JSTL fmt Tag <i><;fmt:setTimeZone>;</i> Example-</b></p>
<p> The <i><b><;fmt:setTimeZone>;</b></i> is used to set the required time zone value. We can also copy the time zone object into the scoped variable for later use.</p>
<p>In JSP <i><b><;fmt:setTimeZone>;</b></i> tag of JSTL fmt tag library is used to set a specified time zone or default time zone. The specified time zone may be either a specific name of time zone, supported by java or an instance of the TimeZone class of Java&#8217;s utility package and the name or an instance can be passed into the required attribute named &#8220;value&#8221; of this tag.</p>
<p><b>Attributes of <i><;fmt:setTimeZone>;</i> tag</b><br />
<b>value : </b>This is a required attribute that specifies the name of a time zone/time zone IDs supported by java or an instance of the <b><i>java.util.TimeZone.</i></b><br />
<b>var : </b>This is an optional attribute that defines the name of the scoped variable kept the time zone of <i><b>java.util.TimeZone</b></i> type.<br />
<b>scope :</b> This is an optional attribute that may be used for specifying the scope of the attribute &#8216;var&#8217;.</p>
<p><b>Syntax-</b><br />
<i><;fmt:setTimeZone value=&#8221;<;string>;&#8221; var=&#8221;<;string>;&#8221; scope=&#8221;<;string>;&#8221;/>;</i><br />
 ;<br />
The following JSP code displays the current date using the default time zone and assigns the time zone to the GMT-8 using the <b><i><;fmt:setTimeZone>;</i></b> tag. Also displays the date using the newly set time zone.</p>
<pre class="highlight" name="code"><;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>;
 <;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>;
 <;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>;
<;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
 "http://www.w3.org/TR/html4/loose.dtd">;
<;html>;
 <;head>;
 <;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">;
 <;title>;&;lt;fmt:setTimeZone&;gt; Demo<;/title>;
 <;/head>;
 <;body>;
 <;h1>;&;lt;fmt:setTimeZone&;gt; Demo<;/h1>;
 <;c:set var="today" value="<;%=new java.util.Date()%>;" />;
 <;p>;Date in the current time zone: 
 <;strong>;
 <;fmt:formatDate value="${today}" type="both" timeStyle="long" dateStyle="long" />;
 <;/strong>;<;/p>;
 <;fmt:setTimeZone value="GMT-8" />;
 <;p>;Date in the GMT-8 time zone: 
 <;strong>;
 <;fmt:formatDate value="${today}" type="both" timeStyle="long" dateStyle="long" />;
 <;/strong>;<;/p>;
 <;/body>;
<;/html>;
</pre>
<p><b><br />
</b> <b>Output-</b></p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="http://50.87.249.200/~dineshon/wp-content/uploads/2013/10/333-3.png" /></div>
<p>
</div>
</div>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/10/jstl-fmt-tag-setbundle-example.html">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/2013/10/jsp-standard-tag-library-jstl-tutorial.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/10/jstl-fmt-tag-message-example.html">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jstl-fmt-tag-setbundle-example/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jstl-fmt-tag-message-example/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '301'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…