Here you can find the source of getServerOffset(boolean useDaylightSavingTime)
public static int getServerOffset(boolean useDaylightSavingTime)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static int getServerOffset(boolean useDaylightSavingTime) { boolean observingDaylightSavingTime = false; final int DST = 1; // New calendar to use as a reference point. Calendar today = new GregorianCalendar(); // TimeZone set to 'EST' for GMT comparison so we can determine the offset. TimeZone serverTimeZone = TimeZone.getTimeZone("America/New_York"); // First getTime() returns date, the second getTime() converts that to milliseconds since the default date in java. int offsetMilliseconds = serverTimeZone.getOffset(today.getTime().getTime()); // 3600000 = 1000 (ms in a sec) * 60 (sec in a min) * 60 (min in a hour) int offsetHours = (offsetMilliseconds / 3600000); // If server is on DST since our servers are EDT if (offsetHours == -4) { observingDaylightSavingTime = true; }// w w w. j a v a 2s . c o m if (observingDaylightSavingTime && useDaylightSavingTime) { offsetHours -= DST; } return offsetHours; } }