Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to detect Time Zone(city) and correctly show individual local time?
How to detect Time Zone(city) and correctly show individual local time? [message #1403481] Thu, 24 July 2014 05:52 Go to next message
David Lee is currently offline David LeeFriend
Messages: 78
Registered: May 2013
Member
Hi, you all,

Q1: How to detect the Time Zone(City) of the client?
Description : In order to know what city the user is in, such as New York/Tokyo and so on.

Q2: How to automatically convert the time difference?
Description : In case the RAP application server is in Tokyo, the timestamp column will record a datetime like 2014-07-24 14:00:00.000000+09 in Tokyo, but the user in New York is supposed to see the corresponding time 2014-07-24 01:00:00.000000-05.

Thank you!


Best Regards,
David

[Updated on: Thu, 24 July 2014 05:53]

Report message to a moderator

Re: How to detect Time Zone(city) and correctly show individual local time? [message #1403489 is a reply to message #1403481] Thu, 24 July 2014 07:43 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi David,
use ClientInfo service to obtain the user time zone like:
---------
ClientInfo service = RWT.getClient().getService( ClientInfo.class );
if( service != null ) {
int timezoneOffset = service.getTimezoneOffset();
}
---------
For zone conversion use standard Java classes and calculate it manually:
---------
Calendar.getInstance( Locale.JAPAN ).getTimeZone()

HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to detect Time Zone(city) and correctly show individual local time? [message #1403661 is a reply to message #1403489] Fri, 25 July 2014 01:05 Go to previous messageGo to next message
David Lee is currently offline David LeeFriend
Messages: 78
Registered: May 2013
Member
Hi, Ivan,

Thank you for your quick reply.

I tried API ClientInfo, it does provide the locale and time offset, but what I need is to get the real Timezone ID of a client user, the Timezone ID is exactly in the format of like 'Asia/Tokyo' 'America/Los_Angeles' and so on. In other words, I want to know where the client user is, the location in the form of like 'America/Los_Angeles'!
Just like RWT.getRequest().getRemoteAddr() can easily get the client user's IP, is there an API that can get the client user's Timezone ID?


Best Regards,

David

[Updated on: Fri, 25 July 2014 01:21]

Report message to a moderator

Re: How to detect Time Zone(city) and correctly show individual local time? [message #1403666 is a reply to message #1403661] Fri, 25 July 2014 07:14 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi David,
there is no API for obtaining the client user's Timezone ID - only the
offset. Did you try TimeZone.getTimeZone(...)?
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to detect Time Zone(city) and correctly show individual local time? [message #1403687 is a reply to message #1403666] Fri, 25 July 2014 10:44 Go to previous message
David Lee is currently offline David LeeFriend
Messages: 78
Registered: May 2013
Member
Hi, Ivan,

Yes, I did! TimeZone.getTimeZone() is to trnsfer a known Timezone ID string from "String" into "Timezone".

Or maybe my question is now supposed to be, How to Find Location Using IP Address in RAP?
Thank you!


Best Regards,

David
Previous Topic:How to supply translations for the text in splash html?
Next Topic:RAP 2.3 - high CPU load with IE 10
Goto Forum:
  


Current Time: Fri Apr 19 23:09:02 GMT 2024

Powered by FUDForum. Page generated in 0.04048 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top