cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r264921 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
Date Wed, 31 Aug 2005 02:18:06 GMT
Author: antonio
Date: Tue Aug 30 19:18:00 2005
New Revision: 264921

URL: http://svn.apache.org/viewcvs?rev=264921&view=rev
Log:
Fix 36373: getTime(...) of CocoonLogFormatter implemented incorrectly
Thanks to Johan Stuyts (j.stuyts@hippo.nl)

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java?rev=264921&r1=264920&r2=264921&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
Tue Aug 30 19:18:00 2005
@@ -23,12 +23,11 @@
 import org.apache.cocoon.util.ExceptionUtils;
 
 import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang.time.FastDateFormat;
 import org.apache.log.ContextMap;
 import org.apache.log.LogEvent;
 import org.apache.log.Logger;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.Map;
 
 /**
@@ -76,7 +75,7 @@
     protected final static String  TYPE_QUERY_STR       = "query";
     protected final static String  TYPE_ROOTTHROWABLE_STR = "rootThrowable";
 
-    protected final static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("(yyyy-MM-dd)
HH:mm.ss:SSS");
+    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) HH:mm.ss:SSS";
 
     /**
      * Hack to get the call stack as an array of classes. The
@@ -299,10 +298,17 @@
      * Utility method to format time.
      *
      * @param time the time
-     * @param format ancilliary format parameter - allowed to be null
+     * @param pattern ancilliary pattern parameter - allowed to be null
      * @return the formatted string
      */
-    protected String getTime(final long time, final String format) {
-        return DATE_FORMATTER.format(new Date());
+    protected String getTime(final long time, String pattern) {
+        String result;
+
+        if (pattern == null) {
+            pattern = DEFAULT_TIME_PATTERN;
+        }
+        FastDateFormat format = FastDateFormat.getInstance(pattern);
+        result = format.format(time);
+        return result;
     }
 }



Mime
View raw message