<?xml version="1.0"?>
<document>

<properties>
  <title>Fast Date Time (FDT)</title>
  <author email="dev@commons.apache.org">Commons Documentation Team</author>
</properties>

<body>

<section name="Java Data and Time synchronization bottleneck analysis">

<p>Here is an anlysis of all the thread synchronization bottlenecks in
the java Data and Time related classes.</p>

<subsection name="java.util.TimeZone">

<p>The following methods are all synchronized:
<ul>
<li><code>public static synchronized TimeZone getTimeZone(String ID)</code></li>
<li><code>public static synchronized String[] getAvailableIDs(int rawOffset)</code></li>
<li><code>public static synchronized String[] getAvailableIDs()</code></li>
<li><code>public static synchronized TimeZone getDefault()</code></li>
<li><code>public static synchronized void setDefault(TimeZone zone)</code></li>
</ul>
The worst offender here is the <code>getDefault()</code> method which is used
frequently by the other Data and Time classes.</p>

</subsection>

<subsection name="java.util.Date">

<p>
The following constructors implement synchronization on a static
object, although these constructors are deprecated, they are still
being used:
<ul>
<li><code>public Date(int year, int month, int date)</code></li>
<li><code>public Date(int year, int month, int date, int hrs, int min)</code></li>
<li><code>public Date(int year, int month, int date, int hrs, int min, int sec)</code></li>
</ul>
</p>

<p>The following methods have a synchronization bottleneck on either a
static object or <code>TimeZone.getDefault()</code>, although these
methods are deprecated, they are still being used:
<ul>
<li><code>public int getTimezoneOffset()</code></li>
<li><code>public int getYear()</code></li>
<li><code>public int getMonth()</code></li>
<li><code>public int getDate()</code></li>
<li><code>public int getDay()</code></li>
<li><code>public int getHours()</code></li>
<li><code>public int getMinutes()</code></li>
<li><code>public int getSeconds()</code></li>
</ul>
</p>

<p>The following methods use <code>TimeZone.getDefault()</code> which has a
synchronization bottleneck:
<ul>
<li><code>public String toString()</code></li>
</ul>
</p>

</subsection>

<subsection name="java.util.Calendar">

<p>The following constructor has a synchronization bottleneck from using
<code>TimeZone.getDefault()</code>:
<ul>
<li><code>protected Calendar()</code></li>
</ul>
</p>

<p>All of the static <code>Calendar.getInstance()</code> methods are synchronized.
</p>

<p>The <code>static Calendar.getInstance()</code> and 
<code>Calendar.getInstance(Locale aLocale)</code> methods use 
<code>GregorianCalendar()</code> constructors which use the
<code>TimeZone.getDefault()</code> sysnchronization bottleneck.
</p>

<p>The <code>static Calendar.getAvailableLocales()</code> is synchronized.
</p>

</subsection>

<subsection name="java.util.GregorianCalendar">

<p>The following constructors use the <code>TimeZone.getDefault()</code>
bottlneck:
<ul>
<li><code>public GregorianCalendar()</code></li>
<li><code>public GregorianCalendar(Locale aLocale)</code></li>
<li><code>public GregorianCalendar(int year, int month, int date)</code></li>
<li><code>public GregorianCalendar(int year, int month, int date, int hour, int minute)</code></li>
<li><code>public GregorianCalendar(int year, int month, int date, int hour, int minute, int second)</code></li>
</ul>
</p>

</subsection>

<subsection name="java.text.SimpleDateFormat">

<p>All of the constructors for <code>SimpleDateFormat</code> have a
synchronization bottleneck from using <code>TimeZone.getDefault()</code>.
</p>

<p>The method <code>public Date parse(String text, ParsePosition pos)</code>
can trigger a synchronization bottleneck when parsing a timezone in the
text string.
</p>

</subsection>

<subsection name="java.sql.Date">

<p>Because this class extends <code>java.util.Date</code> it is susceptible
to most of the synchronization bottlenecks in <code>java.util.Date</code>.
</p>

<p>The method <code>public static Date valueOf(String s)</code> uses a
<code>java.util.Date</code> constructor which has the synchronization
bottleneck.
</p>

<p>The <code>toString()</code> method is a big offender, it triggers a
synchronization bottleneck in <code>java.util.Date</code> three to six
times.
</p>

</subsection>

<subsection name="java.sql.Time">

<p>Because this class extends <code>java.util.Date</code> it is
susceptible to all of the synchronization bottlenecks in
<code>java.util.Date</code>.
</p>

<p>The method <code>public static Time valueOf(String s)</code> ends
up using a <code>java.util.Date</code> constructor which has the
synchronization bottleneck.
</p>

<p>The <code>toString()</code> method is a big offender, it triggers a
synchronization bottleneck in <code>java.util.Date</code> three to six
times.
</p>

</subsection>

<subsection name="java.sql.Timestamp">

<p>Because this class extends <code>java.util.Date</code> it is susceptible
to all of the synchronization bottlenecks in <code>java.util.Date</code>.
</p>

<p>The method <code>public static Timestamp valueOf(String s)</code>
ends up using a <code>java.util.Date</code> constructor which has the
synchronization bottleneck.
</p>

<p>The <code>toString()</code> method is a big offender, it triggers a
synchronization bottleneck in <code>java.util.Date</code> six to twelve
times.
</p>

</subsection>

</section>

</body>

</document>
