Anyone know a good way of getting a java.util.TimeZone object corresponding to the users timezone (that doesnt involve having them manually specify it at login which is what Im looking at having to do now), so that I can display various dates to them in local time?
I thought of getting the difference between the users local time and gmt(utc) based on the value of javascript's Date.getTimezoneOffset() function (using the current date) submitting this in a hidden field on the login page and then instantiating a 'custom' timezone based on this - but this wont take into account the daylight savings rules that apply to the users location - thus certain datetimes will end up being rendered incorrectly when I show them in the users local time... (For example if the date is for a time during dst and the user is currently not in dst or vice versa) I also thought of rendering the dates as javscript code that instantiates a javascript Date object based on the dates utc value and then renders itself into the appropriate location into the dom which would thus be making use of JavaScripts support for the users local daylight savings rules on a per-date basis, but following experimentation it seems that (in IE at least) this doesnt provide any language sensitive rendering - always using English, so Ive ruled this out (kind of a relief considering how much bother and how hack-ish it is!). Of course if I can just get the dratted TimeZone, then its a simple matter to convert the date in question into a suitable string for display to that user: TimeZone timeZone = supplied by magic - arrgh! Locale locale = supplied by struts :-) String formatString = "EEE MMM dd HH:mm:ss zzz yyyy"; //Or some nicer looking format DateFormat df = new SimpleDateFormat(formatString,locale); df.setTimeZone(timeZone); String displayDateText = df.format(date); -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>