1 17 package org.apache.log.output.io.rotate; 18 19 import java.io.File ; 20 import java.text.SimpleDateFormat ; 21 import java.util.Date ; 22 23 30 public class RotateStrategyByDate 31 implements RotateStrategy 32 { 33 private SimpleDateFormat m_format; 34 private Date m_date; 35 private String m_current; 36 37 40 public RotateStrategyByDate() 41 { 42 this( "yyyyMMdd" ); 43 } 44 45 50 public RotateStrategyByDate( final String pattern ) 51 { 52 m_format = new SimpleDateFormat ( pattern ); 53 m_date = new Date (); 54 m_current = m_format.format( m_date ); 55 } 56 57 60 public void reset() 61 { 62 m_date.setTime( System.currentTimeMillis() ); 63 m_current = m_format.format( m_date ); 64 } 65 66 73 public boolean isRotationNeeded( final String data, final File file ) 74 { 75 m_date.setTime( System.currentTimeMillis() ); 76 if( m_current.equals( m_format.format( m_date ) ) ) 77 { 78 return false; 79 } 80 return true; 81 } 82 } 83 | Popular Tags |