Main objective of this tutorial is to help you to get Time according to the Different Time Zone.


You will get Final Output:

  • Time Zone Demo
  • Time Zone Demo
  • Time Zone Demo

Step 1

First create new Android Project. Add Following into your Main Activity class

private Spinner spinnerAvailableID;
private Calendar current;
private TextView textTimeZone, txtCurrentTime, txtTimeZoneTime;
private long miliSeconds;
private ArrayAdapter<String> idAdapter;
private SimpleDateFormat sdf;
private Date resultdate;

Then in our Main Activity class we need all IDs of the different Time Zone. So we use.

String[] idArray = TimeZone.getAvailableIDs();

Step 2 getGMTTime() method implementation

Add new method for converting the current time into GMT (Greenwich Mean Time).

private void getGMTTime() {
current = Calendar.getInstance();
txtCurrentTime.setText("" + current.getTime());
miliSeconds = current.getTimeInMillis();
TimeZone tzCurrent = current.getTimeZone();
int offset = tzCurrent.getRawOffset();
if (tzCurrent.inDaylightTime(new Date())) {
offset = offset + tzCurrent.getDSTSavings();
miliSeconds = miliSeconds - offset;
resultdate = new Date(miliSeconds);

To know more about Calendar class please follow the link:


Step 3 onCreate() Method

Then Add the following code into your onCreate() method.

        spinnerAvailableID = (Spinner) findViewById(;
textTimeZone = (TextView) findViewById(;
txtCurrentTime = (TextView) findViewById(;
txtTimeZoneTime = (TextView) findViewById(;
sdf = new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm:ss");
idAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, idArray);
.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
String selectedId = (String) (parent
TimeZone timezone = TimeZone.getTimeZone(selectedId);
String TimeZoneName = timezone.getDisplayName();
int TimeZoneOffset = timezone.getRawOffset()
/ (60 * 1000);
int hrs = TimeZoneOffset / 60;
int mins = TimeZoneOffset % 60;
miliSeconds = miliSeconds + timezone.getRawOffset();
resultdate = new Date(miliSeconds);
textTimeZone.setText(TimeZoneName + " : GMT " + hrs + "."
+ mins);
txtTimeZoneTime.setText("" + sdf.format(resultdate));
miliSeconds = 0;
public void onNothingSelected(AdapterView<?> arg0) {

More information about SimpleDateFormat class please follow the link:

I hope you enjoy this tutorial and it would be helpful to you.

Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Android App Development Company in India.

An entrepreneur who has founded 2 flourishing software firms in 7 years, Tejas is keen to understand everything about gaming - from the business dynamics to awesome designs to gamer psychology. As the founder-CEO of a company that has released some very successful games, he knows a thing or two about gaming. He shares his knowledge through blogs and talks that he gets invited to.

face mask Belial The Demon Headgear Pocket Staff Magic