directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r265770 - /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java
Date Thu, 01 Sep 2005 19:22:54 GMT
Author: elecharny
Date: Thu Sep  1 12:22:50 2005
New Revision: 265770

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

Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java?rev=265770&r1=265769&r2=265770&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java
(original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/DateUtils.java
Thu Sep  1 12:22:50 2005
@@ -31,6 +31,13 @@
 {
 	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 +106,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 );
+    	}
     } 
 }
 



Mime
View raw message