Default Android Time zone List

android, list, timezone

Solution

   String[] ids=TimeZone.getAvailableIDs();
   for(int i=0;i<ids.length;i++)
   {
       System.out.println("Availalbe ids.................."+ids[i]);
       TimeZone d= TimeZone.getTimeZone(ids[i]);
       System.out.println("time zone."+d.getDisplayName());
       System.out.println("savings."+d.getDSTSavings());
       System.out.println("offset."+d.getRawOffset());

      /////////////////////////////////////////////////////
      if (!ids[i].matches(".*/.*")) {
          continue;
      }

      String region = ids[i].replaceAll(".*/", "").replaceAll("_", " ");
      int hours = Math.abs(d.getRawOffset()) / 3600000;
      int minutes = Math.abs(d.getRawOffset() / 60000) % 60;
      String sign = d.getRawOffset() >= 0 ? "+" : "-";

      String timeZonePretty = String.format("(UTC %s %02d:%02d) %s", sign, hours, minutes, region);
      System.out.println(timeZonePretty);
      //////////////////////////////////////////////////////////////////
   }
    ListView listitems=(ListView)findViewById(R.id.list);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,ids);
   listitems.setAdapter(adapter);
  }

The documentation for TimeZone.http://developer.android.com/reference/java/util/TimeZone.html

To set time zone

Following is sample code for settings Time Zone of according to America

  // First Create Object of Calendar Class
  Calendar calendar = Calendar.getInstance();        
  // Now Set the Date using DateFormat Class
  SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss z"); 
  // Finally Set the time zone using SimpleDateFormat Class's setTimeZone() Method
  sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); 

Problem

I was wondering if i can get somewhere the default code for time zone selection list for android version 2.3.3?

Original source