I want the user to select a timezone and then display a the server systemdate 
in the users timezone...
switching the timezone seems to work, but the page will always display the same 
date, no matter, which timezone I select.

first I wrote a small stateless bean, to get the available timezones and the 
current date:


  | @Stateless
  | @Name("timeZoneUtil")
  | public class TimeZoneUtil implements Serializable, TimeZoneUtilInterface {
  | 
  |     public List<SelectItem> getTimeZones() {
  |             String[] timeZoneIDs = java.util.TimeZone.getAvailableIDs();
  |             List<SelectItem> selectItems = new ArrayList<SelectItem>(
  |                             timeZoneIDs.length);
  |             for (String name : timeZoneIDs) {
  |                     selectItems.add(new SelectItem(name, name));
  |             }
  |             return selectItems;
  |     }
  |     
  |     public Date getCurrentDateTime() {
  |             return new Date();
  |     }
  | ...
  | }
  | 

in the webpage, I use the standard seam functions to switch the locale and 
display the date/time:


  |     <h:form id="change_tz">
  |             <h:selectOneMenu value="#{timeZoneSelector.timeZoneId}">
  |                 <f:selectItems value="#{timeZoneUtil.timeZones}"/>
  |             </h:selectOneMenu>
  |             <h:commandButton action="#{timeZoneSelector.select}" 
value="Timezone"/>
  |     </h:form>    
  |     
  |     <div>CurrentDateTime:
  |             timezone: #{timeZoneSelector.timeZone}
  |             <p>
  |             <h:outputText value="#{timeZoneUtil.currentDateTime}">
  |               <s:convertDateTime type="both" dateStyle="full"/>
  |             </h:outputText>
  |             </p>
  |     </div>
  | 

Switching the locale seems to work, but the page will always display the same 
date!?
e.g. 
anonymous wrote : 
  | CurrentDateTime: timezone: 
sun.util.calendar.ZoneInfo[id="Etc/GMT+10",offset=-36000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
  | 
  | Dienstag, 11. Dezember 2007 16:22:04 
  | 
some seconds later:

anonymous wrote : 
  | CurrentDateTime: timezone: 
sun.util.calendar.ZoneInfo[id="Etc/GMT+12",offset=-43200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
  | 
  | Dienstag, 11. Dezember 2007 16:22:39 
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111969#4111969

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111969
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to