Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

User time zone

Dear Experts,

I have following problem. Portal server and end-user are situated in different time zones. In my portal component I need to show end-user time, i.e. local time for user. But if I call function

Calendar.getInstance().getTime()

it returns a local time of server and not a local time of user.

As I know, I can get time zone information from user personalization:

((IUser) request.getUser()).getTimeZone()

But often, users don't define they time zone information. I suppose, there is ability to get such information from request object, because, as I know, http-browser transmits time zone information in http-request.

But all my attempts to get this information from request was not successful:

request.getLocale()
request.getUser().getLocale()

Both functions don't return time zone information.

Does anybody have any ideas about it?

Former Member
replied

Hi Egor,

> I know, http-browser transmits time zone information

> in http-request

IE? If I call www.google.com, I cannot see the TZ anywhere, checked by HTTPWatch. There is also no corresponding setting within IE. You could only map prefered languages to locales, but that doesn't work really proper, for they work over different time zones.

Also see http://www.timeanddate.com/worldclock - no automatic detection.

Also see http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=Enterprisejava&Number=12640&page=1&view=collapsed&sb=9&o=&fpart=1

So I would suggest to use the user's time zone, and if not set, to use the server's time. It's the fault of the user admins if the time zone is not set!

> Both functions don't return time zone information

Right. And as said, mapping the locale to a time zone is a (bad) workaround, nothing I would advise.

Hope it helps

Detlev

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question