computing time based on TimeZones
<p>my code computes the date and time correctly  including the dayLightSaving time,when run on my local server from india. But when I run the same code from US server I am getting the time which is one hour ahead for the timeZoneId which is not abserving DST.</p>

<pre><code>TimeZone tz = TimeZone.getTimeZone("America/Phoenix");
Date currTime = getDateByTZ(new Date(), tz);
System.out.println("currTime" + currTime);

public static Date getDateByTZ(Date d, TimeZone tz) throws Exception {

    if (tz == null) {
        tz = TimeZone.getDefault();
    }
    Integer tzOffSet = tz.getRawOffset();
    Integer tzDST = tz.getDSTSavings();
    Integer defOffSet = TimeZone.getDefault().getRawOffset();
    Integer defDST = TimeZone.getDefault().getDSTSavings();
    Calendar cal = Calendar.getInstance(tz);
    cal.setTime(d);
    if (tz.inDaylightTime(d)) {
        cal.add(Calendar.MILLISECOND, -defOffSet);
        cal.add(Calendar.MILLISECOND, -defDST);
        cal.add(Calendar.MILLISECOND, +tzOffSet);
        cal.add(Calendar.MILLISECOND, +tzDST);
    } else {
        cal.add(Calendar.MILLISECOND, -defOffSet);
        cal.add(Calendar.MILLISECOND, tzOffSet);
    }
    return cal.getTime();
}
</code></pre>

<p>Results from Localserver:</p>

<blockquote>
  <p>currTime:Mon Oct 22 01:52:21 IST 2012</p>
</blockquote>

<p>Results from USserver:</p>

<blockquote>
  <p>currTime:Mon Oct 22 02:52:21 IST 2012</p>
</blockquote>
