<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>convertDateTime | LogikDevelopment</title>
	<atom:link href="https://www.logikdev.com/tag/convertdatetime/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.logikdev.com</link>
	<description>&#34;Il n&#039;y a pas de problème, il n&#039;y a que des solutions. L&#039;esprit de l&#039;homme invente ensuite le problème.&#34; André Gide</description>
	<lastBuildDate>Tue, 25 Apr 2017 13:57:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>
	<item>
		<title>Clock change affecting date display</title>
		<link>https://www.logikdev.com/2010/09/18/clock-change-affecting-date-display/</link>
					<comments>https://www.logikdev.com/2010/09/18/clock-change-affecting-date-display/#respond</comments>
		
		<dc:creator><![CDATA[smoreau]]></dc:creator>
		<pubDate>Sat, 18 Sep 2010 12:04:16 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[BST]]></category>
		<category><![CDATA[convertDateTime]]></category>
		<category><![CDATA[GMT]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[outputText]]></category>
		<category><![CDATA[time zone]]></category>
		<guid isPermaLink="false">https://www.logikdev.com/?p=771</guid>

					<description><![CDATA[<p>This is a very particular problem which happens only during the summer and not even in all the countries ! 😮 The problem is related to the Daylight Saving Time (DST), also called British Summer Time (BST): Daylight saving time is the practice of temporarily advancing clocks so that afternoons have more daylight and mornings [&#8230;]</p>
<p>The post <a href="https://www.logikdev.com/2010/09/18/clock-change-affecting-date-display/">Clock change affecting date display</a> first appeared on <a href="https://www.logikdev.com">LogikDevelopment</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>This is a very particular problem which happens only during the summer and not even in all the countries ! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f62e.png" alt="😮" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
The problem is related to the Daylight Saving Time (DST), also called British Summer Time (BST):</p>
<blockquote><p>
Daylight saving time is the practice of temporarily advancing clocks so that afternoons have more daylight and mornings have less. Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn.
</p></blockquote>
<p>Okay, so how do we display dates with JSF?<br />
Let&#8217;s take this can&#8217;t-be-simpler bean:</p>
<pre class="brush: java; title: ; notranslate">
public class MyBean {
	public Date getDate() {
		return new Date();
	}
}
</pre>
<p>And let&#8217;s insert the following code in a JSF page:</p>
<pre class="brush: xml; title: ; notranslate">
#{myBean.date}
</pre>
<p>The result is <code>Fri Sep 17 20:03:14 BST 2010</code> (when I wrote this article).<br />
If I check my clock, the date and time above are correct.<br />
So far so good. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Let&#8217;s now use the <code>h:outputText</code> tag from JSF:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h:outputText value=&quot;#{myBean.date}&quot;/&gt;
</pre>
<p>The result is <code>Sep 17, 2010</code>.<br />
Alright, the date is correct but the time is not displayed&#8230;</p>
<p>Let&#8217;s use the <code>f:convertDateTime</code> tag to also display the time:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h:outputText value=&quot;#{myBean.date}&quot;&gt;
	&lt;f:convertDateTime pattern=&quot;E MMM dd HH:mm:ss z yyyy&quot; /&gt;
&lt;/h:outputText&gt;
</pre>
<p>The result is <code>Fri Sep 17 19:03:14 GMT 2010</code>.<br />
What can we see here? The time went one hour backward!<br />
Why that? well, simply because the date is now displayed in GMT, instead of BST earlier.</p>
<p>So, this means that the <code>h:outputText</code> tag is displaying the date in GMT by default, which would be fine in winter but not in summer.<br />
In order to fix this behaviour, you need to add the attribute <code>timeZone</code> to the <code>f:convertDateTime</code> tag such as:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h:outputText value=&quot;#{myBean.date}&quot;&gt;
	&lt;f:convertDateTime pattern=&quot;E MMM dd HH:mm:ss z yyyy&quot; timeZone=&quot;GB&quot; /&gt;
&lt;/h:outputText&gt;
</pre>
<p>Note that if you put <code>BST</code> instead of <code>GB</code> in the <code>timeZone</code> attribute, the time zone is going to be actually set to <strong>BDST</strong> which stands for Bangladesh Daylight Saving Time! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p><p>The post <a href="https://www.logikdev.com/2010/09/18/clock-change-affecting-date-display/">Clock change affecting date display</a> first appeared on <a href="https://www.logikdev.com">LogikDevelopment</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.logikdev.com/2010/09/18/clock-change-affecting-date-display/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
