Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out GMT offset value in android

Tags:

android

gmt

How to find out the values of GMT for user for example it is +05:30 for India. How do calculate this +05:30 value in Android ?

I need this because I am using a java library in my app which has a function with this +05:30 field and I want to generate this field by calculation so that I wont have to fill up individual values for countries.

like image 525
user3671032 Avatar asked Jan 19 '26 17:01

user3671032


1 Answers

This is what works awesome

   public double getOffset(){
        TimeZone timezone = TimeZone.getDefault();
        int seconds = timezone.getOffset(Calendar.ZONE_OFFSET)/1000;
        double minutes = seconds/60;
        double hours = minutes/60;
        return hours;
  }
like image 84
user3671032 Avatar answered Jan 22 '26 22:01

user3671032



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!