JodaOrg/joda-time — pull request #48 by codematters (2013-07-26 13:45:18+00:00)
Title: Reduce synchronization in LocalDateTime.toDate()

Background:
Our application uses Joda internally but dates have to be converted to java.util.Date in various locations. We perform thousands of LocalDateTime.toDate() operations per second. Unfortunately, this can lead to threads being blocked briefly, on account of java.util.Date's internal synchronization when getting the default time zone.

Adding a toDate(TimeZone zone) method makes it possible to perform such conversions without hitting the synchronization overhead. The reduction in synchronization allows our application to perform ~5% more transactions/second.

Patch details:
java.util.Date uses TimeZone.getDefaultRef() internally, mostly when
using deprecated constructors or deprecated field accessors.
TimeZone.getDefaultRef() is synchronized, concurrent calls to
LocalDateTime.toDate() can thus come with a costly
synchronization/blocking overhead.

This patch reduces the need to get the default time zone by adding a new
LocalDateTime.toDate(TimeZone zone) method, as well as by using a
java.util.Calendar in toDate()'s DST correction code.

These changes make it possible to convert LocalDateTime to
java.util.Date without any synchronization overhead.

Note:
Previous pull request was wrong, forgot to amend a commit before pushing.