avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate RotateStrategyByDate.java
Date Thu, 21 Feb 2002 11:34:07 GMT
colus       02/02/21 03:34:07

  Added:       src/java/org/apache/log/output/io/rotate
                        RotateStrategyByDate.java
  Log:
  Added date format rotate stratgey for log file per day.
  Renamed to RotateStrategyByDate.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyByDate.java
  
  Index: RotateStrategyByDate.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.log.output.io.rotate;
  
  import java.io.File;
  import java.util.Date;
  import java.text.SimpleDateFormat;
  
  /**
   * Rotation stragety based on SimpleDateFormat.
   *
   * @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
   * @version $Revision: 1.1 $ $Date: 2002/02/21 11:34:07 $
   */
  public class RotateStrategyByDate
      implements RotateStrategy
  {
      private SimpleDateFormat m_format;
      private Date m_date;
      private String m_current;
  
      public RotateStrategyByDate( final String pattern )
      {
          m_format = new SimpleDateFormat( pattern );
          m_date = new Date();
          m_current = m_format.format( m_date );
      }
  
      public void reset()
      {
          m_current = m_format.format( m_date );
      }
  
      public boolean isRotationNeeded( final String data, final File file )
      {
          m_date.setTime( System.currentTimeMillis() );
          if ( m_current.equals( m_format.format( m_date ) ) )
          {
              return true;
          }
          return false;
      }
  }
  
  

--
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