Bug 6436 - Timezone Doesn't work when formatting a date
Summary: Timezone Doesn't work when formatting a date
Alias: None
Product: Taglibs
Classification: Unclassified
Component: DateTime Taglib (show other bugs)
Version: 1.0B1
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2002-02-13 20:22 UTC by Ralph Ltnn
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Ltnn 2002-02-13 20:22:09 UTC
When using the taglib library, I'm tring to format a java.util.Date with a 
pattern as well as a timezone.  However, I can't seem to get the Timzone piece 
to work.  Here's a sample piece of code...

<dt:timeZone id="tz">myObject.getTimeZone().getID()</dt:timeZone>
<dt:format pattern="MM/dd/yy hh:mm:ss a z" timeZone="tz"

Where myObject.getTimeZone().getID() returns "MST" and
      item.getDateDue() returns a java.util.Date

Whenever I run this code, the output always shows in GMT.
Comment 1 Glenn Nielsen 2002-04-04 18:11:23 UTC
Sorry it has taken me this long to look into this.
I see a problem with your code.

<dt:timeZone id="tz">myObject.getTimeZone().getID()</dt:timeZone>

The above tries to set the time zone to the string literal
"myObject.getTimeZone().getID()" instead of its value.  If the
timezone tag is passed an invalid timezone string it uses the
system default.

Try this:

<dt:timeZone id="tz"><%= myObject.getTimeZone().getID() %></dt:timeZone>

The problem looks like it is in your code, not the taglib.