The question seems quite simple but I would really appreciate the help. Search the internet many times.
Following is the code to get current timezone of Android Devices in GMT:
Java.Util.Calendar mCalendar = new Java.Util.GregorianCalendar();
Java.Util.TimeZone mTimeZone = mCalendar.TimeZone;
int mGMTOffset = mTimeZone.RawOffset + (mTimeZone.InDaylightTime(new Java.Util.Date()) ? mTimeZone.DSTSavings : 0);
string timeDiff = Java.Util.Concurrent.TimeUnit.Hours.Convert(mGMTOffset, Java.Util.Concurrent.TimeUnit.Milliseconds).ToString();
Outputs:
If Mobile time is GMT-03:00 Then timeDiff = -3
If Mobile time is GMT+00:00 Then timeDiff = 0
If Mobile time is GMT+05:00 Then timeDiff = 5
If Mobile time is GMT+05:45 Then timeDiff = 5 (In Correct)
Issue comes when GMT is in decimal values like 5:45 shows 5.
What should I do in these types of scenarios?
I took help from the following link How to get the timezone offset in GMT(Like GMT+7:00) from android device?