Yeh, I was considering that. For now it will default to whatever timezone the server is in (as the folk doing the ejb side of things havent time to provide me persistence for it).
As most of the users will be on an intranet and the server in the same timezone as them (or configured to render dates as though it is in the same timezone as them) that should cover 80% of cases without users having to lift a finger. The other 20% would probably be road warriors who might be moving about a fair bit. -----Original Message----- From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, 9 January 2003 22:06 To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: [OT][JavaScript][i18n] How to get a date with a user? One pickup line I've heard is "Excuse me, do you have the time?", but I've never used it myself as I make it a policy not to date my users. Seriously, another option is to have user Preferences that are supplied at registration time and can be edited later. Then they don't have to keep supplying their Timezone at each login and you don't have to muck with Javascript. But I would also be curious to see a stable cross-browser Javascript solution to this problem. > -----Original Message----- > From: Andrew Hill [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 09, 2003 6:35 AM > To: Struts > Subject: [OT][JavaScript][i18n] How to get a date with a user? > > > 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]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>