I want to get the timezone on an android device with respect to UTC. For example, if I'm in PST timezone, then I want it in this format: "-0800". Is it possible?
Asked
Active
Viewed 1,043 times
0
-
Please add an example – Lisa Anne Feb 27 '13 at 19:48
-
my device in PST time-zone. I get "PST" for the above. I want to represent "PST" time zone in form of/with respect to "UTC". For example, PST could be represented as "UTC-08:00". I don't know how to achieve it. – bianca Feb 27 '13 at 20:09
1 Answers
1
This snippet gives me PST timezone represented as "-0800", which is UTC representation for PST. It was just a matter of formatting. Thanks to SimpleDateFormat class.
Calendar cal = Calendar.getInstance(Locale.getDefault()); String
timezoneStr = new SimpleDateFormat("Z").format(cal.getTime());