Returns the ID of this TimeZone, such as America/Los_Angeles, GMT-08:00 or UTC. - Android java.util

Android examples for java.util:Calendar

Description

Returns the ID of this TimeZone, such as America/Los_Angeles, GMT-08:00 or UTC.

Demo Code


import java.util.Calendar;

public class Main {
  /**//from   w ww  . j  av a2s.  c om
   * Returns the ID of this TimeZone, such as America/Los_Angeles, GMT-08:00 or
   * UTC.
   * 
   * @return
   */
  public static final String obtainTimeZone() {
    String zone = null;
    try {
      zone = Calendar.getInstance().getTimeZone().getID();
    } catch (Exception e) {

    }
    if (zone == null) {
      zone = "";
    }
    return zone;
  }
}

Related Tutorials