You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/01 21:23:59 UTC

svn commit: r265771 - /directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java

Author: elecharny
Date: Thu Sep  1 12:23:56 2005
New Revision: 265771

URL: http://svn.apache.org/viewcvs?rev=265771&view=rev
Log:
Synchronized SimpleDateFormat

Modified:
    directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java

Modified: directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java?rev=265771&r1=265770&r2=265771&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java (original)
+++ directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/util/DateUtils.java Thu Sep  1 12:23:56 2005
@@ -31,6 +31,12 @@
 {
 	private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
 	
+    private static final DateFormat dateFormat = new SimpleDateFormat( "yyyyMMddHHmmss'Z'" );
+    
+    static 
+    {
+    	dateFormat.setTimeZone( UTC_TIME_ZONE );
+    }
     /**
      * Gets the generalized time using the "Z" form of the g-time-zone
      * described by [<a href=
@@ -99,9 +105,12 @@
      */ 
     public static String getGeneralizedTime()
     {
-      DateFormat date = new SimpleDateFormat( "yyyyMMddHHmmss'Z'" );
-      date.setTimeZone( UTC_TIME_ZONE );
-      return date.format( new Date() );
+    	Date date = new Date();
+    	
+    	synchronized (dateFormat)
+    	{
+    		return dateFormat.format( date );
+    	}
     } 
 }