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 7190547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:32:25+00:00 2026-05-28T19:32:25+00:00

I developed a sample clock (Analog) application to display the time. Now my application

  • 0

I developed a sample clock (Analog) application to display the time. Now my application shows the current time of my mobile. I wish to improve it for showing world times. Unfortunately I don’t have much knowledge in this, can any one guide me?

  • 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-28T19:32:26+00:00Added an answer on May 28, 2026 at 7:32 pm

    Here is the code i used to display all cities times.

    Main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    
    </LinearLayout>
    

    timezone.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:orientation="vertical" >
    
        <TextView
            android:id="@+id/timezone_name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="25dip" />
    
        <TextView
            android:id="@+id/timezone_time"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="15dip" />
    
    </LinearLayout>
    

    The class files are…

    MainActivity.java

    package com.practice.secondhand;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import java.util.TimeZone;
    
    import android.app.ListActivity;
    import android.content.Context;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.TextView;
    
    public class MainActivity extends ListActivity {
        protected static final int UPDATE_UI = 0;
    
        TimeZoneAdaptor timezoneAdaptor = null;
        List<TimeZoneData> timezonelist = null;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            timezonelist = new ArrayList<TimeZoneData>();
            timezoneAdaptor = new TimeZoneAdaptor(this, R.layout.timezoneview,
                    timezonelist);
    
            setListAdapter(timezoneAdaptor);
        }
    
        @Override
        protected void onStart() {
            super.onStart();
    
            String[] listItems = TimeZone.getAvailableIDs();
    
            TimeZone timezone = null;
            SimpleDateFormat format = new SimpleDateFormat(
                    "EEE, MMM d, yyyy h:mm a");
            Date now = new Date();
    
            for (int index = 0; index < listItems.length; ++index) {
                timezone = TimeZone.getTimeZone(listItems[index]);
    
                format.setTimeZone(timezone);
    
                timezonelist.add(new TimeZoneData(getDiaplayName(listItems[index]),
                        format.format(now)));
    
                timezone = null;
            }
        }
    
        private String getDiaplayName(String timezonename) {
            String displayname = timezonename;
            int sep = timezonename.indexOf('/');
    
            if (-1 != sep) {
                displayname = timezonename.substring(0, sep) + ", "
                        + timezonename.substring(sep + 1);
                displayname = displayname.replace("_", " ");
            }
    
            return displayname;
        }
    
        public class TimeZoneAdaptor extends ArrayAdapter<TimeZoneData> {
    
            List<TimeZoneData> objects = null;
    
            public TimeZoneAdaptor(Context context, int textViewResourceId,
                    List<TimeZoneData> objects) {
                super(context, textViewResourceId, objects);
    
                this.objects = objects;
            }
    
            @Override
            public int getCount() {
                return ((null != objects) ? objects.size() : 0);
            }
    
            @Override
            public TimeZoneData getItem(int position) {
                return ((null != objects) ? objects.get(position) : null);
            }
    
            @Override
            public long getItemId(int position) {
                return position;
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = convertView;
    
                if (null == view) {
                    LayoutInflater vi = (LayoutInflater) MainActivity.this
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    view = vi.inflate(R.layout.timezoneview, null);
                }
    
                TimeZoneData data = objects.get(position);
    
                if (null != data) {
                    TextView textName = (TextView) view
                            .findViewById(R.id.timezone_name);
                    TextView textTime = (TextView) view
                            .findViewById(R.id.timezone_time);
    
                    textName.setText(data.name);
                    textTime.setText(data.time);
                }
    
                return view;
            }
        }
    }
    

    TimeZoneData.java

    package com.practice.secondhand;
    
    
    public class TimeZoneData {
            public String name;
            public String time;
    
            public TimeZoneData(String name,String time) {
                    this.name = name;
                    this.time = time;
            }
    }
    

    TimeZoneAdaptor .java

    public class TimeZoneAdaptor extends ArrayAdapter<TimeZoneData> {
    
        List<TimeZoneData> objects = null;
    
        public TimeZoneAdaptor(Context context, int textViewResourceId,
                List<TimeZoneData> objects) {
            super(context, textViewResourceId, objects);
    
            this.objects = objects;
        }
    
        public int getCount() {
            return ((null != objects) ? objects.size() : 0);
        }
    
        public TimeZoneData getItem(int position) {
            return ((null != objects) ? objects.get(position) : null);
        }
    
        public long getItemId(int position) {
            return position;
        }
    
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;
    
            if (null == view) {
                LayoutInflater vi = (LayoutInflater) TimeZonesList.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = vi.inflate(R.layout.timezoneview, null);
            }
    
            TimeZoneData data = objects.get(position);
    
            if (null != data) {
                TextView textName = (TextView) view
                        .findViewById(R.id.timezone_name);
                TextView textTime = (TextView) view
                        .findViewById(R.id.timezone_time);
                textName.setTextSize(18);
                textName.setTextColor(Color.GREEN);
                textName.setText(data.name);
                textTime.setText(data.time);
                textTime.setTextSize(15);
    
            }
    
            return view;
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: error is showing for Digital Clock widget Application in Android I want
I'm doing shared hosting with GoDaddy and I developed a sample ASP.NET MVC app
I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I have developed a simple location aware iPhone application which is functionally working very
i developed a very simple vb.net application and i need a way for every
I've developed a very simple ASP.NET (jQuery) application. The RDBMS is MS Sql Server
I have made a sample application in which I am able to implement help
I've developed a Facebook application using the Facebook C# SDK. Interestingly, whenever the user
I created a sample audio player application in android. In my application I used
Consider i have a window Application,developed in Visual Studio 2005, having a button. I

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.