title: TimeZone.setDefault changes in JDK6
body: <p>I just noticed that JDK 6 has a different approach to setting a default TimeZone than JDK5. </p>
  
  <p>Previously the new default would be stored in a thread-local variable. With JDK6 (I just reviewed 1.6.0.18) the implementation has changed, so that if the user can write to the "user.timezone" property, or if there is no SecurityManager installed, the timezone changes VM-wide! Otherwise a thread-local change occurs.</p>
  
  <p>Am I wrong? This seems to be quite a drastic change, and I couldn't find anything on the web about it.</p>
  
  <p>Here is the JDK6 code:</p>
  
  <pre><code> private static boolean hasPermission() {
    boolean hasPermission = true;
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
     try {
      sm.checkPermission(new PropertyPermission("user.timezone", "write"));
     } catch (SecurityException e) {
      hasPermission = false;
     }
    }
    return hasPermission;
   }
  
   /**
    * Sets the &lt;code&gt;TimeZone&lt;/code&gt; that is
    * returned by the &lt;code&gt;getDefault&lt;/code&gt; method.  If &lt;code&gt;zone&lt;/code&gt;
    * is null, reset the default to the value it had originally when the
    * VM first started.
    * @param zone the new default time zone
    * @see #getDefault
    */
   public static void setDefault(TimeZone zone)
   {
    if (hasPermission()) {
     synchronized (TimeZone.class) {
      defaultTimeZone = zone;
      defaultZoneTL.set(null);
     }
    } else {
     defaultZoneTL.set(zone);
    }
   }
  </code></pre>
  
  <p>while before (in JDK5) it was simply:</p>
  
  <pre><code> /**
    * Sets the &lt;code&gt;TimeZone&lt;/code&gt; that is
    * returned by the &lt;code&gt;getDefault&lt;/code&gt; method.  If &lt;code&gt;zone&lt;/code&gt;
    * is null, reset the default to the value it had originally when the
    * VM first started.
    * @param zone the new default time zone
    * @see #getDefault
    */
   public static synchronized void setDefault(TimeZone zone)
   {
    defaultZoneTL.set(zone);
   }
  </code></pre>