incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1021670 - in /sling/branches/eventing-3.0/src/main/java/org/apache/sling/event: EventUtil.java impl/jobs/console/WebConsolePlugin.java
Date Tue, 12 Oct 2010 08:33:13 GMT
Author: cziegeler
Date: Tue Oct 12 08:33:13 2010
New Revision: 1021670

URL: http://svn.apache.org/viewvc?rev=1021670&view=rev
Log:
Print calendar objects as date objects and use date formatter for the web console

Modified:
    sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
    sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java

Modified: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java?rev=1021670&r1=1021669&r2=1021670&view=diff
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java (original)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java Tue Oct
12 08:33:13 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.event;
 
+import java.util.Calendar;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -304,7 +305,18 @@ public abstract class EventUtil {
                 }
                 buffer.append(names[i]);
                 buffer.append('=');
-                buffer.append(e.getProperty(names[i]));
+                final Object value = e.getProperty(names[i]);
+                // the toString() method of Calendar is very verbose
+                // therefore we do a toString for these objects based
+                // on a date
+                if ( value instanceof Calendar ) {
+                    buffer.append(value.getClass().getName());
+                    buffer.append('(');
+                    buffer.append(((Calendar)value).getTime());
+                    buffer.append(')');
+                } else {
+                    buffer.append(value);
+                }
             }
         }
         buffer.append("]");

Modified: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java?rev=1021670&r1=1021669&r2=1021670&view=diff
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
(original)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
Tue Oct 12 08:33:13 2010
@@ -20,6 +20,8 @@ package org.apache.sling.event.impl.jobs
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
 
@@ -203,7 +205,7 @@ public class WebConsolePlugin extends Ht
     }
 
     /**
-     * Format an array.
+     * Format an array for html rendering.
      */
     private String formatArray(final String[] array) {
         if ( array == null || array.length == 0 ) {
@@ -231,16 +233,23 @@ public class WebConsolePlugin extends Ht
         return Arrays.toString(array);
     }
 
-    /** TODO */
-    private String formatDate(final long time) {
+    /** Default date format used. */
+    private final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSS yyyy-MMM-dd");
+
+    /**
+     * Format a date
+     */
+    private synchronized String formatDate(final long time) {
         if ( time == -1 ) {
             return "-";
         }
         final Date d = new Date(time);
-        return d.toString();
+        return dateFormat.format(d);
     }
 
-    /** TODO */
+    /**
+     * Format time (= duration)
+     */
     private String formatTime(final long time) {
         if ( time == 0 ) {
             return "-";



Mime
View raw message