Time Zones with f:convertDateTime in JSF

Although it is not mentioned in the spec, the default time zone for f:convertDateTime in 1.2 is GMT, as you can see here.

To convert times for São Paulo, for example, you need to write:

<f:convertDateTime type="time" timeStyle="medium" timeZone="America/Sao_Paulo" />

http://en.wikipedia.org/wiki/Zoneinfo

In 2.0+, you can set it to TimeZone.getDefault() instead in the web.xml file:

<context-param>
  <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
  <param-value>true</param-value>
</context-param>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s