How to get the timezone offset in UTC (like UTC+03:00
) from Android device? I'm able to retrieve timezone offset in GMT format (which looks like GMT+03:00
) with help of this code:
TimeZone.getDefault().getDisplayName(false, TimeZone.SHORT)
by I can't to retrieve timezone offset in UTC format (what I want actually retrieve is something like UTC+03:00
). How to achieve this?
UPD
It seems that it's something wrong with java.util.TimeZone
class, because
val timeZoneGMT = TimeZone.getTimeZone("GMT")
Log.d("OLOLO ","Time zone GMT: " + timeZoneGMT.getDisplayName(false, TimeZone.SHORT))
outputs
Time zone GMT: GMT+00:00
but at the same time
val timeZone = TimeZone.getTimeZone("UTC")
Log.d("OLOLO ","Time zone UTC: " + timeZone.getDisplayName(false, TimeZone.SHORT))
outputs just this:
Time zone UTC: UTC