Re: freemarker calendar display format with time zone info

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Monday, September 29, 2008, 8:58:38 AM, Bionicoder wrote:

> Hi gurus,
>
> I have a question about how to display java.util.calendar  's time zone in
> FTL. The "time zone" I am talking about is the time zone set in calendar,
> instead of the time zone set in local machine.
>
> The problem I got is the parsed FTL always display the local machine's time
> zone and the time based on the local machine time zone. It CAN NOT display
> the time zone set in calendar.  For example, my server's time zone setting
> is America/Los Angles (PDT). One customer object has a calendar time
> property whose time zone is America/new York (EDT). In web page display, it
> always display the PDT time zone, instead of EDT. 
>
> The format I used in FTL is like:
>
>     <p>The customer local time is: ${cal.time?string("MM-dd-yyyy HH:mm:ss
> zzz")}</p>
>
> cal is the calendar object which has the time zone different from local
> machine 's time zone.
>
> My app is developed on EJB3, mysql, struts2, JSP + freemarker.  One of
> project's requirement is to display customer's time based on their own time
> zone. Customer class is like:
>
> public Class Customer extends Serializable {
>      private long id;
>      private String name;
>      private Calendar cal;  // calendar time
>
>      ......
> }
>
> Please shed some light if you can. I appreciate it.

FreeMarker has a time_zone setting. Regarding settings and how to set
them please see:

http://freemarker.org/docs/pgui_config_settings.html

As you can see there, you can set the time zone before calling the
Template in the Environment, for example based upon the time zone of
the visitor.

> BC

-- 
Best regards,
 Daniel Dekany


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.