[android] How to get the timezone offset in GMT(Like GMT+7:00) from android device?

Use this code (Opt 1):

    //Opt 1
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
            Locale.getDefault());
    Date currentLocalTime = calendar.getTime();
    DateFormat date = new SimpleDateFormat("Z", Locale.getDefault());
    String localTime = date.format(currentLocalTime);
    String finalTimezone = String.format("GMT%s:%s", localTime.substring(0, 3), localTime.substring(3));
    Log.d(TAG, "timezone 1: " + finalTimezone);

    //Opt 2
    date = new SimpleDateFormat("z",Locale.getDefault());
    localTime = date.format(currentLocalTime);
    Log.d(TAG, "timezone 2: "+localTime);

    //Opt 3
    TimeZone tz = TimeZone.getDefault();
    Log.d(TAG, "timezone 3: "+tz.getDisplayName(true, TimeZone.SHORT));
    //

If I'm in Los Angeles (GTM-07:00 Pacific Standard Time) the output is:

timezone 1: GMT-07:00
timezone 2: PDT
timezone 3: PDT