Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5949567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:16:05+00:00 2026-05-22T17:16:05+00:00

In my app, I am using GeoNamesAPI for fetching the current time at any

  • 0

In my app, I am using GeoNamesAPI for fetching the current time at any location.
I have registered for using that.

My code looks like:

Timezone currentTimeZone;
org.geonames.WebService.setUserName("mathew");
currentTimeZone = GeoNamesAPI.fetchTimeZone(latitude, longitude);

The problem is when I check time at any ocean, this currentTimeZone returns null.
So in that case, I show the GMT value.

String time = null;
Integer timeZone = (int) (((longitude / 7.5) + 1) / 2);

if (timeZone >= 0) {
    time = "GMT+" + timeZone;
} else {
    time = "GMT" + timeZone;
}

So the time value will be of the kind GMT+somevalue. I want to find another solution for this case. In this case also I want to display the time value. How can I do that? Is there any way to get the GMT value? Note: I dont want to show the date only time is required.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:16:05+00:00Added an answer on May 22, 2026 at 5:16 pm

    I got it worked. Code is given below:

    Integer timeZone = (int) (((longitude / 7.5) + 1) / 2);
    DateFormat dateformat = DateFormat.getTimeInstance(DateFormat.SHORT);
    dateformat.setTimeZone(TimeZone.getTimeZone("gmt"));
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR, timeZone);   //Adding/Subtracting hour to current date time
    String newdate = dateformat.format(cal.getTime());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a silverlight app using Prism practices; the current code does a search
I have an app using SQLite3. It's running pretty well, but I would like
I have an Codeigniter app (using version 2.1.0) that is writing a transaction to
I have an app using the camera. But each time the app has run
I have an app using using Django Nonrel on AppEngine. I'd like to use
I have an app using a UITabBarController, and I have another view that needs
We are building an app using the MVVM pattern, we have controllers that wire
I have an app (using retain/release, not GC) that maintains an NSArray instance variable,
I have an app using PHP and the PayPal API. The basic way it
I'm making an App using Adobe Flex/Air. I was wondering if there is any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.