Java TimeZone Get getTimeZoneOffset()

Here you can find the source of getTimeZoneOffset()

Description

get Time Zone Offset

License

Apache License

Declaration

public static String getTimeZoneOffset() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

import java.util.GregorianCalendar;
import java.util.Locale;

import java.util.TimeZone;

public class Main {
    public static String getTimeZoneOffset() {
        Calendar cal = Calendar.getInstance();
        TimeZone currentTimeZone = cal.getTimeZone();
        Calendar currentDt = new GregorianCalendar(currentTimeZone,
                Locale.US);/*from ww w . j a  va 2  s .  co  m*/
        int gmtOffset = currentTimeZone.getOffset(currentDt.get(0),
                currentDt.get(1), currentDt.get(2), currentDt.get(5),
                currentDt.get(7), currentDt.get(14));

        int hour = gmtOffset / 3600000;
        int min = Math.abs((gmtOffset - hour * 3600000) / 60000);
        return "" + hour + ":" + min;
    }
}

Related

  1. getTimeZone(final String ID)
  2. getTimeZoneByOffSet(String offSetInString)
  3. getTimezoneDifference(String timezone1, String timezone2)
  4. getTimeZoneID()
  5. getTimeZoneIDs()
  6. getTimeZoneOffset(long t)
  7. getTimezones()
  8. getTimezoneTime(long time, int timezone)
  9. isValidTimeZoneId(String timeZoneId)