JSP - determine user's local time zone

Discussion in 'Java' started by Martin, May 31, 2004.

  1. Martin

    Martin Guest

    Hi,

    Is there any way to determine (or even guess?) the time zone from which a
    user is making a request to a JSP server? java.util.TimeZone.getDefault()
    gets the time zone of the server running the application, so that route
    doesn't seem to help and getting the user's Locale isn't accurate enough, as
    I can't, for example, determine from which time zone requests in the US are
    being made... any ideas...?



    Thanks,

    Martin.
    Martin, May 31, 2004
    #1
    1. Advertising

  2. On 31 May 2004 12:29:12 -0700, Martin wrote:

    > Is there any way to determine (or even guess?) the time zone from which a
    > user is making a request to a JSP server?


    Ask the user.. [ Be warned it requires the
    'wetware api' plug-in installed and correctly
    configured on the 'user agent', so it's
    effectiveness is patchy at best. ;-) ]

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
    Andrew Thompson, May 31, 2004
    #2
    1. Advertising

  3. Martin

    P.Hill Guest

    Martin wrote:

    > Hi,
    >
    > Is there any way to determine (or even guess?) the time zone from which a
    > user is making a request to a JSP server? java.util.TimeZone.getDefault()
    > gets the time zone of the server running the application, so that route
    > doesn't seem to help and getting the user's Locale isn't accurate enough, as
    > I can't, for example, determine from which time zone requests in the US are
    > being made... any ideas...?


    If you ran similar code in an applet you would get the answer on the VM running
    in the browser, hence in the local machine of the user. Then provide that
    information somehow to Javascript to a form to ...
    I'll leave the entire problem as an exercise for the reader. :)

    -Paul
    P.Hill, May 31, 2004
    #3
  4. Martin

    Roedy Green Guest

    On 31 May 2004 12:29:12 -0700, (Martin) wrote or
    quoted :

    >Is there any way to determine (or even guess?) the time zone from which a
    >user is making a request to a JSP server?


    If you use an applet, it can find out and tell you. See
    http://mindprod.com/jgloss/timezone.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, May 31, 2004
    #4
  5. Martin

    Johnny Storm Guest

    "P.Hill" <> wrote in message
    news:c9g65i$2bk$...
    > Martin wrote:
    >
    > > Hi,
    > >
    > > Is there any way to determine (or even guess?) the time zone from which

    a
    > > user is making a request to a JSP server?

    java.util.TimeZone.getDefault()
    > > gets the time zone of the server running the application, so that route
    > > doesn't seem to help and getting the user's Locale isn't accurate

    enough, as
    > > I can't, for example, determine from which time zone requests in the US

    are
    > > being made... any ideas...?

    >
    > If you ran similar code in an applet you would get the answer on the VM

    running
    > in the browser, hence in the local machine of the user. Then provide that
    > information somehow to Javascript to a form to ...
    > I'll leave the entire problem as an exercise for the reader. :)
    >
    > -Paul
    >


    You may not even need the applet if you're going to use JavaScript anyway.
    Just use JavaScript to grab the local time of the user's computer, and then
    send the info back to the server.
    (Of course, you've lost the whole sandbox principal, but hey, you were
    almost certainly going to lose it anyway.)


    Johnny

    p.s. Any part of post that felt like crap, retort with better crap, please
    ;) . . . .
    Johnny Storm, Jun 1, 2004
    #5
  6. Martin

    P.Hill Guest

    Johnny Storm wrote:
    > "P.Hill" <> wrote in message
    > news:c9g65i$2bk$...
    >
    >>Martin wrote:
    >>>Is there any way to determine (or even guess?) the time zone

    >
    > You may not even need the applet if you're going to use JavaScript anyway.
    > Just use JavaScript to grab the local time of the user's computer, and then
    > send the info back to the server.


    It is not always the case that knowing the time of a location can help you
    determine the timezone. For example, Arizona (USA), sometimes
    keeps the same time as California which it borders and sometimes the
    same time as the other states around it. This is because it does NOT go
    on Daylight Savings Time, AKA summertime. When you live somewere it
    gets 112 degrees F, you want the sun to go down, believe me.
    Going from time to timezone is not a 1 to 1 mapping. Consider also different
    jurisdictions in which the DLS switch over date is not the same
    in all cases. While contigous areas like to keep their switch over
    dates the same for practical reasons, you can't tell where someone
    is coming from just from their wall time.

    -Paul
    P.Hill, Jun 1, 2004
    #6
  7. Martin

    Liz Guest

    "P.Hill" <> wrote in message
    news:c9h81r$tci$...
    > Johnny Storm wrote:
    > > "P.Hill" <> wrote in message
    > > news:c9g65i$2bk$...
    > >
    > >>Martin wrote:
    > >>>Is there any way to determine (or even guess?) the time zone

    > >
    > > You may not even need the applet if you're going to use JavaScript

    anyway.
    > > Just use JavaScript to grab the local time of the user's computer, and

    then
    > > send the info back to the server.

    >
    > It is not always the case that knowing the time of a location can help you
    > determine the timezone. For example, Arizona (USA), sometimes
    > keeps the same time as California which it borders and sometimes the
    > same time as the other states around it. This is because it does NOT go
    > on Daylight Savings Time, AKA summertime. When you live somewere it
    > gets 112 degrees F, you want the sun to go down, believe me.
    > Going from time to timezone is not a 1 to 1 mapping. Consider also

    different
    > jurisdictions in which the DLS switch over date is not the same
    > in all cases. While contigous areas like to keep their switch over
    > dates the same for practical reasons, you can't tell where someone
    > is coming from just from their wall time.
    >
    > -Paul
    >

    Not only that, different Countries change to/from daylight savings
    on days that are not the same as the USA change days.
    Countries in North America (USA, Canada, Mexico) end Standard

    (or Winter) Time on Sunday 4th April 2004.

    The clocks go forward in the whole of the European Union and

    associate countries (including Lithuania which will now observe

    Summer time) a week earlier on Sunday 28th March 2004.
    Liz, Jun 1, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=

    prevent a postback when moving web parts from zone to zone.

    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=, Feb 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    581
    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=
    Feb 8, 2006
  2. =?Utf-8?B?ZHc=?=

    Get browser local time zone?

    =?Utf-8?B?ZHc=?=, Jul 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,179
    =?Utf-8?B?ZHc=?=
    Jul 20, 2006
  3. Replies:
    8
    Views:
    785
    Boris
    May 1, 2007
  4. John Grandy

    determine time-zone of client machine

    John Grandy, Aug 23, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    774
  5. Geoff Robinson
    Replies:
    0
    Views:
    110
    Geoff Robinson
    Jul 31, 2004
Loading...

Share This Page