Here you can find the source of getTimeZoneOffset()
public static String getTimeZoneOffset()
//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; } }