Bug 15839

Summary: fmt:formatDate displays IRT as timezone instead of MET
Product: Taglibs Reporter: georg-schmid
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: 1.0.1   
Target Milestone: ---   
Hardware: Sun   
OS: Solaris   

Description georg-schmid 2003-01-07 14:37:32 UTC
In the following  JSP page

<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.TimeZone" %>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<%
  TimeZone defaultTimeZone = TimeZone.getDefault();
  session.setAttribute( "timeZone", defaultTimeZone );
%>

<fmt:setTimeZone value="${timeZone.ID}"/>

<%
  Calendar today = GregorianCalendar.getInstance();
  today.setTimeZone( defaultTimeZone );
  request.setAttribute( "today", today );
%>

<html>
<head>
</head>

<body>

Default timezone from <code>java.util.TimeZone.getDefault()</code>:
<c:out value="${timeZone}"/>

<h3>
  
  <fmt:formatDate value="${today.time}" type="both" dateStyle="long"
timeStyle="long" />

</h3>

</body>
</html>

the formatDate tag displays 'IRT' as timezone instead of 'MET'.

(Context: Solaris 2.8, Tomcat 4.1.18, JSTL1.0.2, TZ environment variable
is set to 'MET' on the server).

It is really confusing for our (German) users to see times and dates in 'Iranian
Time' instead of 'Middle European Time'.

Regards
Georg Schmid
Comment 1 Pierre Delisle 2003-01-08 20:27:17 UTC
As stated in the Java API documentation, three-letter time zone IDs have 
been deprecated because the same abbreviation is often used for multiple 
time zones. In your case, MET is an alias for "Asia/Tehran".

You should use something like "Europe/Berlin" instead (or whatever the
proper timezone is for you).

    -- Pierre


Comment 2 georg-schmid 2003-01-09 08:15:01 UTC
Hi Pierre,

I researched the problem a bit further and found, that this is related to 
the JDK itself, not the JSTL.

A few points should be noted:
1) MET is "Middle Europe Time", not "Middle Eastern Time" (this is an error 
introduced some time back in JDK1.x. It has been fixed since JDK1.2.2 latest, 
but not for all locales). Set the locale to "en" and you'll see. BTW, this is 
also the interpretation of Solaris 2.8.

2) Using MET was not my idea. The timezone on our Solaris boxes is MET (which 
is standard TZ setting for our region on Solaris), and the JDK reads this 
setting. 

3) It's only the localization, that is wrong. I created a JSP page, that 
prints the zone strings of the DateFormatSymbols for the locale "de". It shows 
that the localization of the timezone strings has been done only half-
heartedly, even in the JDK1.4.1_01-b01. For instance, MET in German would 
be "MEZ" (Mitteleuropaeische Zeit) or the long version of GMT should 
be "Mittlere Greenwich-Zeit", not "Greenwich Mean Time".

4) Localized timezones should work out of the box, without having to pass -
Duser.timezone=Europe/Berlin to the JVM, especially on Solaris.

5) Using "Europe/Berlin" results in the timezone string "CET".

6) I posted a bug report at Sun's Java bug report site.

Regards
Georg Schmid