Hi
I need to get the browser time zone on the Vaadin application
I tried
((WebApplicationContext)this.getContext()).getBrowser().getRawTimezoneOffset() etc. methods present in WebBrowser class
but all of them have no values of the client Time Zone and return default values 0 or the server time
“default values 0 or the server time” So which one does it return. You’re looking in the right spot. There should be a few methods about time zones. They should return the difference in hours between server and client. From there you can use the int to convert it into a timezone with a lookup.
Hi Jens,
I tried ((WebApplicationContext)this.getContext()).getBrowser().getCurrentDate() … this always returns the Date in the server Time Zone , which does not help.
((WebApplicationContext)this.getContext()).getBrowser().getRawTimezoneOffset() … this always returns 0 irrespective of the TZ of the browser client ,
which is also not correct
Hence i need to know if someone has solved this or this is a bug in Vaadin.
Where exactly in your code are you trying to retrieve the timezone? The timezone won’t be availabe until the first client<->server roundtrip has been made i.e. its not available in the Application constructor for instance.
In my case we have a Login View & subsequently the application view , so we put the necessary code after the Login is done.
By this time the application instance has already been created.
I am having issues with this also. In part of my code I am getting the current datetime and using it in the application
[code]
SimpleDateFormat sdfDate = new SimpleDateFormat(“MMM dd yyyy HH:mm”);
String info = sdfDate.format(getUI().getPage().getWebBrowser().getCurrentDate());
return info
[/code]The time I am getting back is one hour before the current time. I have check the time and timezone on both the server and client, and the time setup is correct. When I run in eclipse I do not have this problem and also the popup date time fields have the correct time.
What am I doing wrong, it has got to be something simple?