I am getting the timezone
of a android device using this code
TimeZone tz = TimeZone.getDefault();
String current_Time_Zone = (TimeZone.getTimeZone(tz.getID()).getDisplayName(
false, TimeZone.SHORT))
But it always return me the timezone
like "IST
" but i want to get the timezone in GMT
like this GMT+7:00.
returns like +03:30
To get date time with offset like
2019-07-22T13:39:27.397+05:00
Try following Kotlin code:Output Formate:
If you want other similar formats replace pattern in
SimpleDateFormat
as below:If someone is looking how to represent the GMT as a float number representing hour offset
(for example "GMT-0530" to -5.5), you can use this:
You can do like this:
Yet another solution to get timezone offset: