You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Howard Lin <Ho...@vonage.com> on 2003/06/12 19:50:35 UTC
RE: timeZone and day light saving time
Do something like this in the jsp page:
<%-- timzone w/o dst --%>
<fmt:setTimeZone value="GMT-5" var="tz"/>
<%
TimeZone tz = (TimeZone)pageContext.getAttribute("tz");
SimpleTimeZone stz = new SimpleTimeZone(tz.getRawOffset(), tz.getID(), 3, 1, 1, 7200000, 9, -1, 1, 7200000, 3600000);
pageContext.setAttribute("stz", stz);
%>
<%-- using timezone with dst rule -->
<fmt:formatDate value="${date_time}" type="both" pattern="yyyy-MM-dd HH:mm" var="formated_date_time" timeZone="${stz}" />
Check Javadoc of SimpleTimeZone for DST rules in the constructor.
Howard
> -----Original Message-----
> From: Mike Deegan [mailto:mpdeegan@hotmail.com]
> Sent: Thursday, June 12, 2003 1:25 PM
> To: Howard Lin
> Subject: Re: timeZone and day light saving time
>
>
> can you supply a listing of the code
> i'm a novice on the timezone front
>
> tia
> mike
>
> ----- Original Message -----
> From: "Howard Lin" <ho...@vonage.com>
> To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
> Sent: Thursday, June 12, 2003 10:53 AM
> Subject: RE: timeZone and day light saving time
>
>
> I found a solution myself. Just in case anybody else wants to
> do the same
> thing, here is what I did: create a SimpleTimeZone in a
> script with DST
> rule, and then set this timezone in the pageContext. Then using this
> timezone in <fmt:parseDate> or <fmt:formatDate>. It works.
>
> Howard Lin
>
> > -----Original Message-----
> > From: Howard Lin
> > Sent: Wednesday, June 11, 2003 3:08 PM
> > To: 'Tag Libraries Users List' (E-mail)
> > Subject: timeZone and day light saving time
> >
> >
> > It seems that there is no way to specify Day Light Saving
> > Time rule in <fmt:timeZone> or <fmt:setTimeZone> since it's
> > implemented as Java TimeZone, not SimpleTimeZone. Is there
> > way to specify day light saving timezone? Thanks,
> >
> > Howard Lin
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> taglibs-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
RE: timeZone and day light saving time
Posted by Kris Schneider <kr...@dotech.com>.
It seems like you should be able to do what you want without that much trouble.
If the time zone is given as a string, it's parsed using
java.util.TimeZone.getTimeZone(). For example:
<fmt:timeZone value="America/Bogota">
...
</fmt:timeZone>
<fmt:timeZone value="America/Detroit">
...
</fmt:timeZone>
Both have the same raw offset but have different daylight savings behavior. I
suppose the trick is knowing which of the supported time zone IDs to use
(TimeZone.getAvailableIDs can get you a list). Here's a list of the IDs for "GMT-5":
America/Bogota
America/Cayman
America/Detroit
America/Eirunepe
America/Fort_Wayne
America/Grand_Turk
America/Guayaquil
America/Havana
America/Indiana/Indianapolis
America/Indiana/Knox
America/Indiana/Marengo
America/Indiana/Vevay
America/Indianapolis
America/Iqaluit
America/Jamaica
America/Kentucky/Louisville
America/Kentucky/Monticello
America/Knox_IN
America/Lima
America/Louisville
America/Montreal
America/Nassau
America/New_York
America/Nipigon
America/Panama
America/Pangnirtung
America/Port-au-Prince
America/Porto_Acre
America/Rio_Branco
America/Thunder_Bay
Brazil/Acre
Canada/Eastern
Cuba
EST
EST5EDT
Etc/GMT+5
IET
Jamaica
SystemV/EST5
SystemV/EST5EDT
US/East-Indiana
US/Eastern
US/Indiana-Starke
US/Michigan
Quoting Howard Lin <Ho...@vonage.com>:
> Do something like this in the jsp page:
>
> <%-- timzone w/o dst --%>
> <fmt:setTimeZone value="GMT-5" var="tz"/>
> <%
> TimeZone tz = (TimeZone)pageContext.getAttribute("tz");
> SimpleTimeZone stz = new SimpleTimeZone(tz.getRawOffset(), tz.getID(), 3, 1,
> 1, 7200000, 9, -1, 1, 7200000, 3600000);
> pageContext.setAttribute("stz", stz);
> %>
> <%-- using timezone with dst rule -->
> <fmt:formatDate value="${date_time}" type="both" pattern="yyyy-MM-dd HH:mm"
> var="formated_date_time" timeZone="${stz}" />
>
> Check Javadoc of SimpleTimeZone for DST rules in the constructor.
>
> Howard
>
> > -----Original Message-----
> > From: Mike Deegan [mailto:mpdeegan@hotmail.com]
> > Sent: Thursday, June 12, 2003 1:25 PM
> > To: Howard Lin
> > Subject: Re: timeZone and day light saving time
> >
> >
> > can you supply a listing of the code
> > i'm a novice on the timezone front
> >
> > tia
> > mike
> >
> > ----- Original Message -----
> > From: "Howard Lin" <ho...@vonage.com>
> > To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
> > Sent: Thursday, June 12, 2003 10:53 AM
> > Subject: RE: timeZone and day light saving time
> >
> >
> > I found a solution myself. Just in case anybody else wants to
> > do the same
> > thing, here is what I did: create a SimpleTimeZone in a
> > script with DST
> > rule, and then set this timezone in the pageContext. Then using this
> > timezone in <fmt:parseDate> or <fmt:formatDate>. It works.
> >
> > Howard Lin
> >
> > > -----Original Message-----
> > > From: Howard Lin
> > > Sent: Wednesday, June 11, 2003 3:08 PM
> > > To: 'Tag Libraries Users List' (E-mail)
> > > Subject: timeZone and day light saving time
> > >
> > >
> > > It seems that there is no way to specify Day Light Saving
> > > Time rule in <fmt:timeZone> or <fmt:setTimeZone> since it's
> > > implemented as Java TimeZone, not SimpleTimeZone. Is there
> > > way to specify day light saving timezone? Thanks,
> > >
> > > Howard Lin
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org