2 Replies Latest reply on Feb 3, 2009 6:03 PM by tathagat

    How to set client timezone


      Hi guys.
      I am creating an internationalised application.

      I need to show users time, according to their timezone. How can I do that?

      I tried the following:

      <h:outputText value="#{testService.test.timestamp}">
           <s:convertDateTime dateStyle="full" type="both" />

      But it shows the time of the tomcat server in different countries. I want it to display the client's local time.

      How can I do that? I guess I have to set timeZone like this:

      <s:convertDateTime dateStyle="full" type="both" timeZone="XYZ" />

      But how do I determine XYZ for user automatically?

      Thanks in advance.

        • 1. Re: How to set client timezone

          I don't think timezone is sent via any standard HTTP header.  Try the timezoneSelector.

          • 2. Re: How to set client timezone

            Thanks for the reply.

            This is what I do to set timezone.

            <h:selectOneMenu value="#{timeZoneSelector.timeZoneId}">
                <f:selectItems value="#{staticDataService.timeZones}"/>
            <h:commandButton action="#{timeZoneSelector.select}" value="#{messages.ChangeTimeZone}"/>

            But then I have the problem that the page doesn't load the new times automatically, unless I refresh the page.
            Also this has to be done every time user logs in. So no cookies are being saved. How do I save cookie for timezone selection?


            <international:locale-selector cookie-enabled="true"/>

            does not help.

            Thanks in advance.