avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-logkit/src/java/org/apache/log/format PatternFormatter.java
Date Wed, 12 Dec 2001 11:39:25 GMT
donaldp     01/12/12 03:39:25

  Modified:    src/java/org/apache/log/format PatternFormatter.java
  Log:
  Made it possible to specify the format of date in the auxilliary parameter of the format
for dates.
  
  Submitted By: "Bachran, Michael" <MBachran@onebridge.de>
  
  Revision  Changes    Path
  1.22      +12 -2     jakarta-avalon-logkit/src/java/org/apache/log/format/PatternFormatter.java
  
  Index: PatternFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/PatternFormatter.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PatternFormatter.java	2001/11/19 12:18:33	1.21
  +++ PatternFormatter.java	2001/12/12 11:39:25	1.22
  @@ -8,6 +8,8 @@
   package org.apache.log.format;
   
   import java.io.StringWriter;
  +import java.text.SimpleDateFormat;
  +import java.util.Date;
   import java.util.Stack;
   import org.apache.log.ContextMap;
   import org.apache.log.ContextStack;
  @@ -71,7 +73,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.21 $ $Date: 2001/11/19 12:18:33 $
  + * @version CVS $Revision: 1.22 $ $Date: 2001/12/12 11:39:25 $
    */
   public class PatternFormatter
       implements Formatter, org.apache.log.Formatter
  @@ -526,7 +528,15 @@
        */
       protected String getTime( final long time, final String format )
       {
  -        return Long.toString( time );
  +        if ( null == format )
  +        {
  +            return Long.toString( time );
  +        }
  +        else
  +        {
  +            final SimpleDateFormat simpleDateFormat = new SimpleDateFormat( format );
  +            return simpleDateFormat.format( new Date( time ) );
  +        }
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message