commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r628103 - /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
Date Fri, 15 Feb 2008 16:16:27 GMT
Author: ebourg
Date: Fri Feb 15 08:16:25 2008
New Revision: 628103

URL: http://svn.apache.org/viewvc?rev=628103&view=rev
Log:
Synchronization of the DateFormat in PropertyListConfiguration

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java?rev=628103&r1=628102&r2=628103&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/plist/PropertyListConfiguration.java
Fri Feb 15 08:16:25 2008
@@ -84,7 +84,7 @@
 public class PropertyListConfiguration extends AbstractHierarchicalFileConfiguration
 {
     /** The default date format, its use must be synchronized */
-    static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("<*'D'yyyy-MM-dd
HH:mm:ss Z>");
+    private static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("<*'D'yyyy-MM-dd
HH:mm:ss Z>");
 
     /** Instance specific format that can be used to format date in differents time zones
*/
     final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(DEFAULT_DATE_FORMAT.toPattern());
@@ -336,19 +336,25 @@
         }
         else if (value instanceof Date)
         {
-            out.print(DATE_FORMAT.format((Date) value));
+            synchronized (DATE_FORMAT)
+            {
+                out.print(DATE_FORMAT.format((Date) value));
+            }
         }
         else if (value instanceof Calendar)
         {
             // change the time zone of the date format
-            Calendar calendar = (Calendar) value;
-            TimeZone previousZone = DATE_FORMAT.getTimeZone();
-            DATE_FORMAT.setTimeZone(calendar.getTimeZone());
+            synchronized (DATE_FORMAT)
+            {
+                Calendar calendar = (Calendar) value;
+                TimeZone previousZone = DATE_FORMAT.getTimeZone();
+                DATE_FORMAT.setTimeZone(calendar.getTimeZone());
 
-            out.print(DATE_FORMAT.format(calendar.getTime()));
+                out.print(DATE_FORMAT.format(calendar.getTime()));
 
-            // restore the previous time zone of the date format
-            DATE_FORMAT.setTimeZone(previousZone);
+                // restore the previous time zone of the date format
+                DATE_FORMAT.setTimeZone(previousZone);
+            }
         }
         else if (value != null)
         {



Mime
View raw message