Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Problem with GMT offset.

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problem with GMT offset.

    I want to write a program that takes input as latitude and longitude of a particular place and gives output as that place country GMT offset. I have done gmt=longitude/15. example: (Chicago) latitude=41.85N, longitude =-87.65W , GMT= -87.65/15 =>-5.8 but chigago actual GMT is GMT-5(this is country based). so how can i decide that which range of lat and longs comes under which country?and how to get Actual GMT. Its not the rounding problem, if i round that to -6 ,then that is GMT offet for other country.. is there any java api's to find location, based on lat longs?? please help me.
    Last edited by sush; May 9th, 2011 at 06:52 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Problem with GMT offset.

    Do you know how you would do this without a program? As in, if you had to do this using only a piece of paper and a pencil (and whatever other resource), would you know how?

    If so, write out what you would do, and you'll have a pretty close approximation to an algorithm.

    If not, google is your friend. I don't really understand what the problem is, so perhaps writing out your problem a little more clearly would help also.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: Problem with GMT offset.

    OK ..The thing is i need java code to find GMT offset for a given latitude and longitude. But Gmt should be country based in which the given city exists. f

    For ex:

    If i give lat longs for Mumbai(city), i should get India GMT(country) not the mumbai gmt,because mumbai is in India. Reason is except some countries each country has only one GMT .

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Problem with GMT offset.

    The short answer to your question is: no, there isn't an easy way to do this.

    You're going to need to rely on a webservice that gives you the timezone for a given city, or a data structure that does the same, possibly from a third party library.

    Other than that, google is your friend.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: Problem with GMT offset.

    Okay, is there any web service code to find city/place name by using inputs as latitude and longitude?

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Problem with GMT offset.

    Quote Originally Posted by sush View Post
    Okay, is there any web service code to find city/place name by using inputs as latitude and longitude?
    Probably. Like I said, for questions like that, google is your friend. We would just be doing the googling for you, which isn't smart because you know your requirements better than we do.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. get GMT Offset when latitude and longitude are inputs
    By jyothi1305 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 7th, 2011, 02:51 AM
  2. Crude method of using offset whilst using BufferedReader - Correct way?
    By Pr0ject-Rec0n in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: May 9th, 2010, 10:59 PM
  3. Read file until EOF from offset each time
    By Pr0ject-Rec0n in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: April 2nd, 2010, 10:13 PM
  4. end of file \ file offset
    By JayRay in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: March 27th, 2010, 05:11 PM